[Python-3000-checkins] r59255 - in python/branches/py3k: Doc/c-api/concrete.rst Doc/library/os.rst Doc/library/sys.rst Include/floatobject.h Lib/test/regrtest.py Lib/test/test_sys.py Objects/floatobject.c PC/pyconfig.h PCbuild9/pythoncore.vcproj Python/sysmodule.c

christian.heimes python-3000-checkins at python.org
Sat Dec 1 13:22:32 CET 2007


Author: christian.heimes
Date: Sat Dec  1 13:22:32 2007
New Revision: 59255

Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Doc/c-api/concrete.rst
   python/branches/py3k/Doc/library/os.rst
   python/branches/py3k/Doc/library/sys.rst
   python/branches/py3k/Include/floatobject.h
   python/branches/py3k/Lib/test/regrtest.py
   python/branches/py3k/Lib/test/test_sys.py
   python/branches/py3k/Objects/floatobject.c
   python/branches/py3k/PC/pyconfig.h
   python/branches/py3k/PCbuild9/pythoncore.vcproj
   python/branches/py3k/Python/sysmodule.c
Log:
Merged revisions 59245-59254 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r59245 | georg.brandl | 2007-11-30 23:04:45 +0100 (Fri, 30 Nov 2007) | 2 lines
  
  Move lchmod() docs to correct place, and add versionadded tags.
........
  r59249 | christian.heimes | 2007-11-30 23:36:10 +0100 (Fri, 30 Nov 2007) | 2 lines
  
  Backport of -r59242:59246 from py3k
  Fixed problem with regrtest caused by the additional of objects to _abcoll.
........
  r59253 | christian.heimes | 2007-12-01 02:03:20 +0100 (Sat, 01 Dec 2007) | 1 line
  
  Although pyconfig.h claims that WIN32 is obsolete it is still required for the locale module. locale.getdefaultlocale() fails silently w/o the WIN32 macro.
........
  r59254 | christian.heimes | 2007-12-01 12:20:10 +0100 (Sat, 01 Dec 2007) | 3 lines
  
  Feature #1534
  Added PyFloat_GetMax(), PyFloat_GetMin() and PyFloat_GetInfo() to the float API.
  Added a dictionary sys.float_info with information about the internal floating point type to the sys module.
........


Modified: python/branches/py3k/Doc/c-api/concrete.rst
==============================================================================
--- python/branches/py3k/Doc/c-api/concrete.rst	(original)
+++ python/branches/py3k/Doc/c-api/concrete.rst	Sat Dec  1 13:22:32 2007
@@ -499,6 +499,23 @@
    without error checking.
 
 
+.. cfunction:: PyObject* PyFloat_GetInfo(void)
+
+   Return a :ctype:`PyDictObject` object which contains information about the
+   precision, minimum and maximum values of a float. It's a thin wrapper
+   around the header file :file:`float.h`.
+
+
+.. cfunction:: double PyFloat_GetMax(void)
+
+   Return the maximum representable finite float *DBL_MAX* as C :ctype:`double`.
+
+
+.. cfunction:: double PyFloat_GetMin(void)
+
+   Return the minimum normalized positive float *DBL_MIN* as C :ctype:`double`.
+
+
 .. _complexobjects:
 
 Complex Number Objects

Modified: python/branches/py3k/Doc/library/os.rst
==============================================================================
--- python/branches/py3k/Doc/library/os.rst	(original)
+++ python/branches/py3k/Doc/library/os.rst	Sat Dec  1 13:22:32 2007
@@ -422,6 +422,8 @@
    Change the mode of the file given by *fd* to the numeric *mode*.  See the docs
    for :func:`chmod` for possible values of *mode*.  Availability: Unix.
 
+   .. versionadded:: 2.6
+
 
 .. function:: fchown(fd, uid, gid)
 
@@ -429,6 +431,8 @@
    and *gid*.  To leave one of the ids unchanged, set it to -1.
    Availability: Unix.
 
+   .. versionadded:: 2.6
+
 
 .. function:: fdatasync(fd)
 
@@ -488,13 +492,6 @@
    tty(-like) device, else ``False``. Availability: Macintosh, Unix.
 
 
-.. function:: lchmod(path, mode)
-
-   Change the mode of *path* to the numeric *mode*. If path is a symlink, this
-   affects the symlink rather than the target. See the docs for :func:`chmod`
-   for possible values of *mode*.  Availability: Unix.
-
-
 .. function:: lseek(fd, pos, how)
 
    Set the current position of file descriptor *fd* to position *pos*, modified by
@@ -800,6 +797,15 @@
    follow symbolic links. Availability: Unix.
 
 
+.. function:: lchmod(path, mode)
+
+   Change the mode of *path* to the numeric *mode*. If path is a symlink, this
+   affects the symlink rather than the target. See the docs for :func:`chmod`
+   for possible values of *mode*.  Availability: Unix.
+
+   .. versionadded:: 2.6
+
+
 .. function:: lchown(path, uid, gid)
 
    Change the owner and group id of *path* to the numeric *uid* and gid. This

Modified: python/branches/py3k/Doc/library/sys.rst
==============================================================================
--- python/branches/py3k/Doc/library/sys.rst	(original)
+++ python/branches/py3k/Doc/library/sys.rst	Sat Dec  1 13:22:32 2007
@@ -184,6 +184,48 @@
    error occurs.
 
 
+.. data:: float_info
+
+   A dict holding information about the float type. It contains low level
+   information about the precision and internal representation. Please study
+   your system's :file:`float.h` for more information.
+
+   +---------------------+--------------------------------------------------+
+   | key                 |  explanation                                     |
+   +=====================+==================================================+
+   | :const:`epsilon`    | Difference between 1 and the next representable  |
+   |                     | floating point number                            |
+   +---------------------+--------------------------------------------------+
+   | :const:`dig`        | digits (see :file:`float.h`)                     |
+   +---------------------+--------------------------------------------------+
+   | :const:`mant_dig`   | mantissa digits (see :file:`float.h`)            |
+   +---------------------+--------------------------------------------------+
+   | :const:`max`        | maximum representable finite float               |
+   +---------------------+--------------------------------------------------+
+   | :const:`max_exp`    | maximum int e such that radix**(e-1) is in the   |
+   |                     | range of finite representable floats             |
+   +---------------------+--------------------------------------------------+
+   | :const:`max_10_exp` | maximum int e such that 10**e is in the          |
+   |                     | range of finite representable floats             |
+   +---------------------+--------------------------------------------------+
+   | :const:`min`        | Minimum positive normalizer float                |
+   +---------------------+--------------------------------------------------+
+   | :const:`min_exp`    | minimum int e such that radix**(e-1) is a        |
+   |                     | normalized float                                 |
+   +---------------------+--------------------------------------------------+
+   | :const:`min_10_exp` | minimum int e such that 10**e is a normalized    |
+   |                     | float                                            |
+   +---------------------+--------------------------------------------------+
+   | :const:`radix`      | radix of exponent                                |
+   +---------------------+--------------------------------------------------+
+   | :const:`rounds`     | addition rounds (see :file:`float.h`)            |
+   +---------------------+--------------------------------------------------+
+
+   .. note::
+
+      The information in the table is simplified.
+
+
 .. function:: getcheckinterval()
 
    Return the interpreter's "check interval"; see :func:`setcheckinterval`.

Modified: python/branches/py3k/Include/floatobject.h
==============================================================================
--- python/branches/py3k/Include/floatobject.h	(original)
+++ python/branches/py3k/Include/floatobject.h	Sat Dec  1 13:22:32 2007
@@ -21,6 +21,10 @@
 #define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
 #define PyFloat_CheckExact(op) (Py_Type(op) == &PyFloat_Type)
 
+PyAPI_FUNC(double) PyFloat_GetMax(void);
+PyAPI_FUNC(double) PyFloat_GetMin(void);
+PyAPI_FUNC(PyObject *) PyFloat_GetInfo(void);
+
 /* Return Python float from string PyObject. */
 PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*);
 

Modified: python/branches/py3k/Lib/test/regrtest.py
==============================================================================
--- python/branches/py3k/Lib/test/regrtest.py	(original)
+++ python/branches/py3k/Lib/test/regrtest.py	Sat Dec  1 13:22:32 2007
@@ -699,10 +699,12 @@
     fs = warnings.filters[:]
     ps = copy_reg.dispatch_table.copy()
     pic = sys.path_importer_cache.copy()
-    abcs = {obj: obj._abc_registry.copy()
-            for abc in [getattr(_abcoll, a) for a in _abcoll.__all__
-                        if issubclass(getattr(_abcoll, a), _Abstract)]
-            for obj in abc.__subclasses__() + [abc]}
+    abcs = {}
+    for abc in [getattr(_abcoll, a) for a in _abcoll.__all__]:
+        if not isinstance(abc, _Abstract):
+            continue
+        for obj in abc.__subclasses__() + [abc]:
+            abcs[obj] = obj._abc_registry.copy()
 
     if indirect_test:
         def run_the_test():

Modified: python/branches/py3k/Lib/test/test_sys.py
==============================================================================
--- python/branches/py3k/Lib/test/test_sys.py	(original)
+++ python/branches/py3k/Lib/test/test_sys.py	Sat Dec  1 13:22:32 2007
@@ -279,6 +279,8 @@
         self.assert_(isinstance(sys.copyright, str))
         self.assert_(isinstance(sys.exec_prefix, str))
         self.assert_(isinstance(sys.executable, str))
+        self.assert_(isinstance(sys.float_info, dict))
+        self.assertEqual(len(sys.float_info), 11)
         self.assert_(isinstance(sys.hexversion, int))
         self.assert_(isinstance(sys.maxint, int))
         self.assert_(isinstance(sys.maxunicode, int))

Modified: python/branches/py3k/Objects/floatobject.c
==============================================================================
--- python/branches/py3k/Objects/floatobject.c	(original)
+++ python/branches/py3k/Objects/floatobject.c	Sat Dec  1 13:22:32 2007
@@ -9,6 +9,7 @@
 #include "formatter_unicode.h"
 
 #include <ctype.h>
+#include <float.h>
 
 #if !defined(__STDC__)
 extern double fmod(double, double);
@@ -48,6 +49,52 @@
 	return p + N_FLOATOBJECTS - 1;
 }
 
+double
+PyFloat_GetMax(void)
+{
+	return DBL_MAX;
+}
+
+double
+PyFloat_GetMin(void)
+{
+	return DBL_MIN;
+}
+
+PyObject *
+PyFloat_GetInfo(void)
+{
+	PyObject *d, *tmp;
+
+#define SET_FLOAT_CONST(d, key, const) \
+	tmp = PyFloat_FromDouble(const); \
+	if (tmp == NULL) return NULL; \
+	if (PyDict_SetItemString(d, key, tmp)) return NULL; \
+	Py_DECREF(tmp)
+#define SET_INT_CONST(d, key, const) \
+	tmp = PyInt_FromLong(const); \
+	if (tmp == NULL) return NULL; \
+	if (PyDict_SetItemString(d, key, tmp)) return NULL; \
+	Py_DECREF(tmp)
+
+	d = PyDict_New();
+
+	SET_FLOAT_CONST(d, "max", DBL_MAX);
+	SET_INT_CONST(d, "max_exp", DBL_MAX_EXP);
+	SET_INT_CONST(d, "max_10_exp", DBL_MAX_10_EXP);
+	SET_FLOAT_CONST(d, "min", DBL_MIN);
+	SET_INT_CONST(d, "min_exp", DBL_MIN_EXP);
+	SET_INT_CONST(d, "min_10_exp", DBL_MIN_10_EXP);
+	SET_INT_CONST(d, "dig", DBL_DIG);
+	SET_INT_CONST(d, "mant_dig", DBL_MANT_DIG);
+	SET_FLOAT_CONST(d, "epsilon", DBL_EPSILON);
+	SET_INT_CONST(d, "radix", FLT_RADIX);
+	SET_INT_CONST(d, "rounds", FLT_ROUNDS);
+
+	return d;
+}
+
+
 PyObject *
 PyFloat_FromDouble(double fval)
 {

Modified: python/branches/py3k/PC/pyconfig.h
==============================================================================
--- python/branches/py3k/PC/pyconfig.h	(original)
+++ python/branches/py3k/PC/pyconfig.h	Sat Dec  1 13:22:32 2007
@@ -23,9 +23,11 @@
 
 
 NOTE: The following symbols are deprecated:
-NT, WIN32, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT
+NT, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT
 MS_CORE_DLL.
 
+WIN32 is still required for the locale module.
+
 */
 
 #ifdef _WIN32_WCE

Modified: python/branches/py3k/PCbuild9/pythoncore.vcproj
==============================================================================
--- python/branches/py3k/PCbuild9/pythoncore.vcproj	(original)
+++ python/branches/py3k/PCbuild9/pythoncore.vcproj	Sat Dec  1 13:22:32 2007
@@ -44,7 +44,7 @@
 				Name="VCCLCompilerTool"
 				AdditionalOptions="/Zm200 "
 				AdditionalIncludeDirectories="..\Python;..\Modules\zlib"
-				PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED"
+				PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;WIN32"
 				RuntimeLibrary="2"
 			/>
 			<Tool
@@ -119,7 +119,7 @@
 				Name="VCCLCompilerTool"
 				AdditionalOptions="/Zm200 "
 				AdditionalIncludeDirectories="..\Python;..\Modules\zlib"
-				PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED"
+				PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;WIN32"
 				RuntimeLibrary="2"
 			/>
 			<Tool
@@ -197,7 +197,7 @@
 				InlineFunctionExpansion="0"
 				EnableIntrinsicFunctions="false"
 				AdditionalIncludeDirectories="..\Python;..\Modules\zlib"
-				PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED"
+				PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;WIN32"
 				RuntimeLibrary="3"
 			/>
 			<Tool
@@ -275,7 +275,7 @@
 				InlineFunctionExpansion="0"
 				EnableIntrinsicFunctions="false"
 				AdditionalIncludeDirectories="..\Python;..\Modules\zlib"
-				PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED"
+				PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;WIN32"
 				RuntimeLibrary="3"
 			/>
 			<Tool
@@ -349,7 +349,7 @@
 				Name="VCCLCompilerTool"
 				AdditionalOptions="/Zm200 "
 				AdditionalIncludeDirectories="..\Python;..\Modules\zlib"
-				PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED"
+				PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;WIN32"
 				RuntimeLibrary="2"
 			/>
 			<Tool
@@ -424,7 +424,7 @@
 				Name="VCCLCompilerTool"
 				AdditionalOptions="/Zm200 "
 				AdditionalIncludeDirectories="..\Python;..\Modules\zlib"
-				PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED"
+				PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;WIN32"
 				RuntimeLibrary="2"
 			/>
 			<Tool
@@ -499,7 +499,7 @@
 				Name="VCCLCompilerTool"
 				AdditionalOptions="/Zm200 "
 				AdditionalIncludeDirectories="..\Python;..\Modules\zlib"
-				PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED"
+				PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;WIN32"
 				RuntimeLibrary="2"
 			/>
 			<Tool
@@ -574,7 +574,7 @@
 				Name="VCCLCompilerTool"
 				AdditionalOptions="/Zm200 "
 				AdditionalIncludeDirectories="..\Python;..\Modules\zlib"
-				PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED"
+				PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;WIN32"
 				RuntimeLibrary="2"
 			/>
 			<Tool

Modified: python/branches/py3k/Python/sysmodule.c
==============================================================================
--- python/branches/py3k/Python/sysmodule.c	(original)
+++ python/branches/py3k/Python/sysmodule.c	Sat Dec  1 13:22:32 2007
@@ -1082,6 +1082,8 @@
 			    PyInt_FromLong(PyInt_GetMax()));
 	SET_SYS_FROM_STRING("maxsize",
 			    PyInt_FromSsize_t(PY_SSIZE_T_MAX));
+	SET_SYS_FROM_STRING("float_info",
+			    PyFloat_GetInfo());
 	SET_SYS_FROM_STRING("maxunicode",
 			    PyInt_FromLong(PyUnicode_GetMax()));
 	SET_SYS_FROM_STRING("builtin_module_names",


More information about the Python-3000-checkins mailing list