Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b76922a

Browse files
committed
Merged revisions 59450-59464 via svnmerge from
svn+ssh://[email protected]/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 python#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... ........
1 parent ad8dcd5 commit b76922a

9 files changed

Lines changed: 54 additions & 9 deletions

File tree

Lib/DocXMLRPCServer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ def docserver(self, server_name, package_documentation, methods):
123123
result = result + '<p>%s</p>\n' % doc
124124

125125
contents = []
126-
method_items = list(methods.items())
127-
method_items.sort()
126+
method_items = sorted(methods.items())
128127
for key, value in method_items:
129128
contents.append(self.docroutine(value, key, funcs=fdict))
130129
result = result + self.bigsection(

Lib/idlelib/FormatParagraph.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def format_paragraph_event(self, event):
7575
else:
7676
text.mark_set("insert", last)
7777
text.see("insert")
78+
return "break"
7879

7980
def find_paragraph(text, mark):
8081
lineno, col = map(int, mark.split("."))

Lib/test/test_float.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ def test_main():
166166
UnknownFormatTestCase,
167167
IEEEFormatTestCase,
168168
FormatTestCase,
169-
ReprTestCase)
169+
#ReprTestCase
170+
)
170171

171172
if __name__ == '__main__':
172173
test_main()

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ Tadayoshi Funaba
225225
Gyro Funch
226226
Peter Funk
227227
Geoff Furnish
228+
Ulisses Furquim
228229
Lele Gaifax
229230
Santiago Gala
230231
Yitzchak Gale

Modules/signalmodule.c

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ static struct {
7575
PyObject *func;
7676
} Handlers[NSIG];
7777

78-
static int is_tripped = 0; /* Speed up sigcheck() when none tripped */
78+
/* Speed up sigcheck() when none tripped */
79+
static volatile sig_atomic_t is_tripped = 0;
7980

8081
static PyObject *DefaultHandler;
8182
static PyObject *IgnoreHandler;
@@ -122,8 +123,10 @@ signal_handler(int sig_num)
122123
/* See NOTES section above */
123124
if (getpid() == main_pid) {
124125
#endif
125-
is_tripped++;
126126
Handlers[sig_num].tripped = 1;
127+
/* Set is_tripped after setting .tripped, as it gets
128+
cleared in PyErr_CheckSignals() before .tripped. */
129+
is_tripped = 1;
127130
Py_AddPendingCall(checksignals_witharg, NULL);
128131
#ifdef WITH_THREAD
129132
}
@@ -597,13 +600,31 @@ PyErr_CheckSignals(void)
597600

598601
if (!is_tripped)
599602
return 0;
603+
600604
#ifdef WITH_THREAD
601605
if (PyThread_get_thread_ident() != main_thread)
602606
return 0;
603607
#endif
608+
609+
/*
610+
* The is_stripped variable is meant to speed up the calls to
611+
* PyErr_CheckSignals (both directly or via pending calls) when no
612+
* signal has arrived. This variable is set to 1 when a signal arrives
613+
* and it is set to 0 here, when we know some signals arrived. This way
614+
* we can run the registered handlers with no signals blocked.
615+
*
616+
* NOTE: with this approach we can have a situation where is_tripped is
617+
* 1 but we have no more signals to handle (Handlers[i].tripped
618+
* is 0 for every signal i). This won't do us any harm (except
619+
* we're gonna spent some cycles for nothing). This happens when
620+
* we receive a signal i after we zero is_tripped and before we
621+
* check Handlers[i].tripped.
622+
*/
623+
is_tripped = 0;
624+
604625
if (!(f = (PyObject *)PyEval_GetFrame()))
605626
f = Py_None;
606-
627+
607628
for (i = 1; i < NSIG; i++) {
608629
if (Handlers[i].tripped) {
609630
PyObject *result = NULL;
@@ -621,7 +642,7 @@ PyErr_CheckSignals(void)
621642
Py_DECREF(result);
622643
}
623644
}
624-
is_tripped = 0;
645+
625646
return 0;
626647
}
627648

@@ -632,7 +653,7 @@ PyErr_CheckSignals(void)
632653
void
633654
PyErr_SetInterrupt(void)
634655
{
635-
is_tripped++;
656+
is_tripped = 1;
636657
Handlers[SIGINT].tripped = 1;
637658
Py_AddPendingCall((int (*)(void *))PyErr_CheckSignals, NULL);
638659
}

Objects/floatobject.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ format_float(char *buf, size_t buflen, PyFloatObject *v, int precision)
281281
format_double(buf, buflen, PyFloat_AS_DOUBLE(v), precision);
282282
}
283283

284+
#ifdef Py_BROKEN_REPR
284285
/* The following function is based on Tcl_PrintDouble,
285286
* from tclUtil.c.
286287
*/
@@ -382,6 +383,8 @@ format_float_repr(char *buf, PyFloatObject *v)
382383
format_double_repr(buf, PyFloat_AS_DOUBLE(v));
383384
}
384385

386+
#endif /* Py_BROKEN_REPR */
387+
385388
/* Macro and helper that convert PyObject obj to a C double and store
386389
the value in dbl. If conversion to double raises an exception, obj is
387390
set to NULL, and the function invoking this macro returns NULL. If
@@ -434,8 +437,14 @@ convert_to_double(PyObject **v, double *dbl)
434437
static PyObject *
435438
float_repr(PyFloatObject *v)
436439
{
440+
#ifdef Py_BROKEN_REPR
437441
char buf[30];
438442
format_float_repr(buf, v);
443+
#else
444+
char buf[100];
445+
format_float(buf, sizeof(buf), v, PREC_REPR);
446+
#endif
447+
439448
return PyUnicode_FromString(buf);
440449
}
441450

@@ -1327,9 +1336,11 @@ _PyFloat_Init(void)
13271336

13281337
double_format = detected_double_format;
13291338
float_format = detected_float_format;
1330-
1339+
1340+
#ifdef Py_BROKEN_REPR
13311341
/* Initialize floating point repr */
13321342
_PyFloat_DigitsInit();
1343+
#endif
13331344
}
13341345

13351346
void

PCbuild/pythoncore.vcproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@
487487
<File
488488
RelativePath="..\Objects\dictobject.c">
489489
</File>
490+
<!--File
491+
RelativePath="..\Objects\doubledigits.c">
492+
</File-->
490493
<File
491494
RelativePath="..\Objects\doubledigits.c">
492495
</File>

PCbuild8/pythoncore/pythoncore.vcproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,10 @@
827827
RelativePath="..\..\Objects\dictobject.c"
828828
>
829829
</File>
830+
<!--File
831+
RelativePath="..\..\Objects\doubledigits.c"
832+
>
833+
</File-->
830834
<File
831835
RelativePath="..\..\Objects\doubledigits.c"
832836
>

PCbuild9/pythoncore.vcproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,10 @@
13621362
RelativePath="..\Objects\dictobject.c"
13631363
>
13641364
</File>
1365+
<!--File
1366+
RelativePath="..\Objects\doubledigits.c"
1367+
>
1368+
</File-->
13651369
<File
13661370
RelativePath="..\Objects\doubledigits.c"
13671371
>

0 commit comments

Comments
 (0)