]> granicus.if.org Git - python/commitdiff
Merged revisions 59450-59464 via svnmerge from
authorChristian Heimes <christian@cheimes.de>
Tue, 11 Dec 2007 01:06:40 +0000 (01:06 +0000)
committerChristian Heimes <christian@cheimes.de>
Tue, 11 Dec 2007 01:06:40 +0000 (01:06 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r59455 | guido.van.rossum | 2007-12-10 21:42:53 +0100 (Mon, 10 Dec 2007) | 2 lines

  Remove a 2.2-ism.
........
  r59459 | christian.heimes | 2007-12-10 23:28:56 +0100 (Mon, 10 Dec 2007) | 4 lines

  Backport of r59456:59458 from py3k to trunk
  Issue #1580: New free format floating point representation based on "Floating-Point Printer Sample Code", by Robert G. Burger. For example repr(11./5) now returns '2.2' instead of '2.2000000000000002'.

  Thanks to noam for the patch! I had to modify doubledigits.c slightly to support X64 and IA64 machines on Windows. I also added the new file to the three project files.
........
  r59460 | guido.van.rossum | 2007-12-11 00:00:12 +0100 (Tue, 11 Dec 2007) | 4 lines

  Patch #1643738 by Ulisses Furquim -- make the is_tripped variable
  in signalmodule.c more robust.  Includes Martin von Loewis's suggestion
  to set is_tripped after .tripped.
........
  r59463 | kurt.kaiser | 2007-12-11 01:04:57 +0100 (Tue, 11 Dec 2007) | 2 lines

  format_paragraph_event wasn't returning 'break'
........
  r59464 | christian.heimes | 2007-12-11 01:54:34 +0100 (Tue, 11 Dec 2007) | 3 lines

  The new float repr causes too much trouble and pain. I'm disabling the feature until we have sorted out the issues on all machines. 64bit machines seem to have issues and Guido has reported even worse.
  Guido: It's pretty bad actually -- repr(1e5) comes out as '1.0'... Ditto for
  repr(1eN) for most N... Both in 2.6 and in 3.0...
........

Lib/DocXMLRPCServer.py
Lib/idlelib/FormatParagraph.py
Lib/test/test_float.py
Misc/ACKS
Modules/signalmodule.c
Objects/floatobject.c
PCbuild/pythoncore.vcproj
PCbuild8/pythoncore/pythoncore.vcproj
PCbuild9/pythoncore.vcproj

index 86c7bfb22578e469d138e2e3f103d4efc4d83329..504b66998827c0609b384771e441c1cc343add9c 100644 (file)
@@ -123,8 +123,7 @@ class ServerHTMLDoc(pydoc.HTMLDoc):
         result = result + '<p>%s</p>\n' % doc
 
         contents = []
-        method_items = list(methods.items())
-        method_items.sort()
+        method_items = sorted(methods.items())
         for key, value in method_items:
             contents.append(self.docroutine(value, key, funcs=fdict))
         result = result + self.bigsection(
index 9b4b3cb000e62a1e4dfa0dc04688d64bdcbbcbbc..02f96d493a3ba12ca2815f412b92110f98597e7b 100644 (file)
@@ -75,6 +75,7 @@ class FormatParagraph:
         else:
             text.mark_set("insert", last)
         text.see("insert")
+        return "break"
 
 def find_paragraph(text, mark):
     lineno, col = map(int, mark.split("."))
index 2ba6dbc7895a587626c6307388ff4364c088c53c..922de7aa04fab5ddfb65d9c685917aed5f004238 100644 (file)
@@ -166,7 +166,8 @@ def test_main():
         UnknownFormatTestCase,
         IEEEFormatTestCase,
         FormatTestCase,
-        ReprTestCase)
+        #ReprTestCase
+        )
 
 if __name__ == '__main__':
     test_main()
index 26bbb0b0b6830ea987a86ecf16ee0a5817380611..17ef503ff0eccbc1f96cd965abd439bfd12a337d 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -225,6 +225,7 @@ Tadayoshi Funaba
 Gyro Funch
 Peter Funk
 Geoff Furnish
+Ulisses Furquim
 Lele Gaifax
 Santiago Gala
 Yitzchak Gale
index 5f38b9b51214876653e1f0980beb6d1cf21bec94..76c8198518c573124f15b6cde08f919aa3fd2483 100644 (file)
@@ -75,7 +75,8 @@ static struct {
         PyObject *func;
 } Handlers[NSIG];
 
-static int is_tripped = 0; /* Speed up sigcheck() when none tripped */
+/* Speed up sigcheck() when none tripped */
+static volatile sig_atomic_t is_tripped = 0;
 
 static PyObject *DefaultHandler;
 static PyObject *IgnoreHandler;
@@ -122,8 +123,10 @@ signal_handler(int sig_num)
        /* See NOTES section above */
        if (getpid() == main_pid) {
 #endif
-               is_tripped++;
                Handlers[sig_num].tripped = 1;
+                /* Set is_tripped after setting .tripped, as it gets
+                   cleared in PyErr_CheckSignals() before .tripped. */
+               is_tripped = 1;
                Py_AddPendingCall(checksignals_witharg, NULL);
 #ifdef WITH_THREAD
        }
@@ -597,13 +600,31 @@ PyErr_CheckSignals(void)
 
        if (!is_tripped)
                return 0;
+
 #ifdef WITH_THREAD
        if (PyThread_get_thread_ident() != main_thread)
                return 0;
 #endif
+
+       /*
+        * The is_stripped variable is meant to speed up the calls to
+        * PyErr_CheckSignals (both directly or via pending calls) when no
+        * signal has arrived. This variable is set to 1 when a signal arrives
+        * and it is set to 0 here, when we know some signals arrived. This way
+        * we can run the registered handlers with no signals blocked.
+        *
+        * NOTE: with this approach we can have a situation where is_tripped is
+        *       1 but we have no more signals to handle (Handlers[i].tripped
+        *       is 0 for every signal i). This won't do us any harm (except
+        *       we're gonna spent some cycles for nothing). This happens when
+        *       we receive a signal i after we zero is_tripped and before we
+        *       check Handlers[i].tripped.
+        */
+       is_tripped = 0;
+
        if (!(f = (PyObject *)PyEval_GetFrame()))
                f = Py_None;
-       
+
        for (i = 1; i < NSIG; i++) {
                if (Handlers[i].tripped) {
                        PyObject *result = NULL;
@@ -621,7 +642,7 @@ PyErr_CheckSignals(void)
                        Py_DECREF(result);
                }
        }
-       is_tripped = 0;
+
        return 0;
 }
 
@@ -632,7 +653,7 @@ PyErr_CheckSignals(void)
 void
 PyErr_SetInterrupt(void)
 {
-       is_tripped++;
+       is_tripped = 1;
        Handlers[SIGINT].tripped = 1;
        Py_AddPendingCall((int (*)(void *))PyErr_CheckSignals, NULL);
 }
index b17f7be996cc6122d3963aabf246dbb922d0f00d..48d29d7042c3902c22016ac4a905b30f5016b334 100644 (file)
@@ -281,6 +281,7 @@ format_float(char *buf, size_t buflen, PyFloatObject *v, int precision)
        format_double(buf, buflen, PyFloat_AS_DOUBLE(v), precision);
 }
 
+#ifdef Py_BROKEN_REPR
 /* The following function is based on Tcl_PrintDouble,
  * from tclUtil.c.
  */
@@ -382,6 +383,8 @@ format_float_repr(char *buf, PyFloatObject *v)
        format_double_repr(buf, PyFloat_AS_DOUBLE(v));
 }
 
+#endif /* Py_BROKEN_REPR */
+
 /* Macro and helper that convert PyObject obj to a C double and store
    the value in dbl.  If conversion to double raises an exception, obj is
    set to NULL, and the function invoking this macro returns NULL.  If
@@ -434,8 +437,14 @@ convert_to_double(PyObject **v, double *dbl)
 static PyObject *
 float_repr(PyFloatObject *v)
 {
+#ifdef Py_BROKEN_REPR
        char buf[30];
        format_float_repr(buf, v);
+#else
+       char buf[100];
+       format_float(buf, sizeof(buf), v, PREC_REPR);
+#endif
+
        return PyUnicode_FromString(buf);
 }
 
@@ -1327,9 +1336,11 @@ _PyFloat_Init(void)
 
        double_format = detected_double_format;
        float_format = detected_float_format;
-       
+
+#ifdef Py_BROKEN_REPR  
        /* Initialize floating point repr */
        _PyFloat_DigitsInit();
+#endif
 }
 
 void
index 326eacc9a925ba0a2f9d694ab099ad498e942a2e..2ac8e25d2753cd659f4d14332e1a6b8aaae6f8e1 100644 (file)
                <File
                        RelativePath="..\Objects\dictobject.c">
                </File>
+               <!--File
+                       RelativePath="..\Objects\doubledigits.c">
+               </File-->
                <File
                        RelativePath="..\Objects\doubledigits.c">
                </File>
index 9a848d72972879ef9e7e44391dfb8a267462666d..1a780225e3200e429afaf73a8ad008354bddb92b 100644 (file)
                                RelativePath="..\..\Objects\dictobject.c"\r
                                >\r
                        </File>\r
+                       <!--File\r
+                               RelativePath="..\..\Objects\doubledigits.c"\r
+                               >\r
+                       </File-->\r
                        <File\r
                                RelativePath="..\..\Objects\doubledigits.c"\r
                                >\r
index 646cb4f9cf678206d07524d126d8114c9c1c830b..42eaa2e4046098a52235f5484480768fc6f1ab74 100644 (file)
                                RelativePath="..\Objects\dictobject.c"
                                >
                        </File>
+                       <!--File
+                               RelativePath="..\Objects\doubledigits.c"
+                               >
+                       </File-->
                        <File
                                RelativePath="..\Objects\doubledigits.c"
                                >