Skip to content

Commit d59c64c

Browse files
committed
Merged revisions 59234-59238 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r59237 | facundo.batista | 2007-11-30 18:15:25 +0100 (Fri, 30 Nov 2007) | 4 lines Reordering of __new__ to minimize isinstance() calls to most used types. Thanks Mark Dickinson. ........ r59238 | christian.heimes | 2007-11-30 20:18:08 +0100 (Fri, 30 Nov 2007) | 6 lines Removed or replaced some more deprecated preprocessor macros. Moved the _DEBUG and NDEBUG macros to two new property files. Fixed #1527 Problem with static libs on Windows Updated README.txt ........
1 parent 45031df commit d59c64c

14 files changed

Lines changed: 172 additions & 146 deletions

Lib/decimal.py

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -540,21 +540,47 @@ def __new__(cls, value="0", context=None):
540540
# digits.
541541

542542
self = object.__new__(cls)
543-
self._is_special = False
544543

545-
# From an internal working value
546-
if isinstance(value, _WorkRep):
547-
self._sign = value.sign
548-
self._int = str(value.int)
549-
self._exp = int(value.exp)
550-
return self
544+
# From a string
545+
# REs insist on real strings, so we can too.
546+
if isinstance(value, str):
547+
m = _parser(value)
548+
if m is None:
549+
if context is None:
550+
context = getcontext()
551+
return context._raise_error(ConversionSyntax,
552+
"Invalid literal for Decimal: %r" % value)
551553

552-
# From another decimal
553-
if isinstance(value, Decimal):
554-
self._exp = value._exp
555-
self._sign = value._sign
556-
self._int = value._int
557-
self._is_special = value._is_special
554+
if m.group('sign') == "-":
555+
self._sign = 1
556+
else:
557+
self._sign = 0
558+
intpart = m.group('int')
559+
if intpart is not None:
560+
# finite number
561+
fracpart = m.group('frac')
562+
exp = int(m.group('exp') or '0')
563+
if fracpart is not None:
564+
self._int = (intpart+fracpart).lstrip('0') or '0'
565+
self._exp = exp - len(fracpart)
566+
else:
567+
self._int = intpart.lstrip('0') or '0'
568+
self._exp = exp
569+
self._is_special = False
570+
else:
571+
diag = m.group('diag')
572+
if diag is not None:
573+
# NaN
574+
self._int = diag.lstrip('0')
575+
if m.group('signal'):
576+
self._exp = 'N'
577+
else:
578+
self._exp = 'n'
579+
else:
580+
# infinity
581+
self._int = '0'
582+
self._exp = 'F'
583+
self._is_special = True
558584
return self
559585

560586
# From an integer
@@ -565,6 +591,23 @@ def __new__(cls, value="0", context=None):
565591
self._sign = 1
566592
self._exp = 0
567593
self._int = str(abs(value))
594+
self._is_special = False
595+
return self
596+
597+
# From another decimal
598+
if isinstance(value, Decimal):
599+
self._exp = value._exp
600+
self._sign = value._sign
601+
self._int = value._int
602+
self._is_special = value._is_special
603+
return self
604+
605+
# From an internal working value
606+
if isinstance(value, _WorkRep):
607+
self._sign = value.sign
608+
self._int = str(value.int)
609+
self._exp = int(value.exp)
610+
self._is_special = False
568611
return self
569612

570613
# tuple/list conversion (possibly from as_tuple())
@@ -616,48 +659,6 @@ def __new__(cls, value="0", context=None):
616659
raise TypeError("Cannot convert float to Decimal. " +
617660
"First convert the float to a string")
618661

619-
# From a string
620-
# REs insist on real strings, so we can too.
621-
if isinstance(value, str):
622-
m = _parser(value)
623-
if m is None:
624-
if context is None:
625-
context = getcontext()
626-
return context._raise_error(ConversionSyntax,
627-
"Invalid literal for Decimal: %r" % value)
628-
629-
if m.group('sign') == "-":
630-
self._sign = 1
631-
else:
632-
self._sign = 0
633-
intpart = m.group('int')
634-
if intpart is not None:
635-
# finite number
636-
fracpart = m.group('frac')
637-
exp = int(m.group('exp') or '0')
638-
if fracpart is not None:
639-
self._int = (intpart+fracpart).lstrip('0') or '0'
640-
self._exp = exp - len(fracpart)
641-
else:
642-
self._int = intpart.lstrip('0') or '0'
643-
self._exp = exp
644-
self._is_special = False
645-
else:
646-
diag = m.group('diag')
647-
if diag is not None:
648-
# NaN
649-
self._int = diag.lstrip('0')
650-
if m.group('signal'):
651-
self._exp = 'N'
652-
else:
653-
self._exp = 'n'
654-
else:
655-
# infinity
656-
self._int = '0'
657-
self._exp = 'F'
658-
self._is_special = True
659-
return self
660-
661662
raise TypeError("Cannot convert %r to Decimal" % value)
662663

663664
def _isnan(self):

PC/dl_nt.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ forgotten) from the programmer.
1111
#include "Python.h"
1212
#include "windows.h"
1313

14+
#ifdef Py_ENABLE_SHARED
1415
char dllVersionBuffer[16] = ""; // a private buffer
1516

1617
// Python Globals
@@ -35,3 +36,5 @@ BOOL WINAPI DllMain (HANDLE hInst,
3536
}
3637
return TRUE;
3738
}
39+
40+
#endif /* Py_ENABLE_SHARED */

PCbuild9/debug.vsprops

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="Windows-1252"?>
2+
<VisualStudioPropertySheet
3+
ProjectType="Visual C++"
4+
Version="8.00"
5+
Name="debug"
6+
>
7+
<Tool
8+
Name="VCCLCompilerTool"
9+
PreprocessorDefinitions="_DEBUG"
10+
/>
11+
</VisualStudioPropertySheet>

PCbuild9/make_buildinfo.vcproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<Configuration
2323
Name="Release|Win32"
2424
ConfigurationType="1"
25-
InheritedPropertySheets=".\pyproject.vsprops"
25+
InheritedPropertySheets=".\pyproject.vsprops;.\release.vsprops"
2626
CharacterSet="0"
2727
>
2828
<Tool
@@ -44,7 +44,7 @@
4444
Name="VCCLCompilerTool"
4545
Optimization="0"
4646
InlineFunctionExpansion="1"
47-
PreprocessorDefinitions="NDEBUG;_CONSOLE"
47+
PreprocessorDefinitions="_CONSOLE"
4848
RuntimeLibrary="0"
4949
/>
5050
<Tool
@@ -87,7 +87,7 @@
8787
<Configuration
8888
Name="Release|x64"
8989
ConfigurationType="1"
90-
InheritedPropertySheets=".\pyproject.vsprops;.\x64.vsprops"
90+
InheritedPropertySheets=".\pyproject.vsprops;.\x64.vsprops;.\release.vsprops"
9191
>
9292
<Tool
9393
Name="VCPreBuildEventTool"
@@ -106,7 +106,7 @@
106106
/>
107107
<Tool
108108
Name="VCCLCompilerTool"
109-
PreprocessorDefinitions="NDEBUG;_CONSOLE"
109+
PreprocessorDefinitions="_CONSOLE"
110110
/>
111111
<Tool
112112
Name="VCManagedResourceCompilerTool"

PCbuild9/make_versioninfo.vcproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<Configuration
2222
Name="Release|Win32"
2323
ConfigurationType="1"
24-
InheritedPropertySheets=".\pyproject.vsprops"
24+
InheritedPropertySheets=".\pyproject.vsprops;.\release.vsprops"
2525
UseOfMFC="0"
2626
ATLMinimizesCRunTimeLibraryUsage="false"
2727
CharacterSet="2"
@@ -50,7 +50,7 @@
5050
InlineFunctionExpansion="1"
5151
EnableIntrinsicFunctions="true"
5252
AdditionalIncludeDirectories=""
53-
PreprocessorDefinitions="NDEBUG;_CONSOLE"
53+
PreprocessorDefinitions="_CONSOLE"
5454
StringPooling="true"
5555
RuntimeLibrary="2"
5656
EnableFunctionLevelLinking="true"
@@ -99,7 +99,7 @@
9999
<Configuration
100100
Name="Release|x64"
101101
ConfigurationType="1"
102-
InheritedPropertySheets=".\pyproject.vsprops;.\x64.vsprops"
102+
InheritedPropertySheets=".\pyproject.vsprops;.\x64.vsprops;.\release.vsprops"
103103
>
104104
<Tool
105105
Name="VCPreBuildEventTool"
@@ -124,7 +124,7 @@
124124
Optimization="2"
125125
InlineFunctionExpansion="1"
126126
EnableIntrinsicFunctions="true"
127-
PreprocessorDefinitions="NDEBUG;_CONSOLE"
127+
PreprocessorDefinitions="_CONSOLE"
128128
/>
129129
<Tool
130130
Name="VCManagedResourceCompilerTool"
@@ -165,7 +165,7 @@
165165
<Configuration
166166
Name="Debug|Win32"
167167
ConfigurationType="1"
168-
InheritedPropertySheets=".\pyproject.vsprops"
168+
InheritedPropertySheets=".\pyproject.vsprops;.\debug.vsprops"
169169
UseOfMFC="0"
170170
ATLMinimizesCRunTimeLibraryUsage="false"
171171
CharacterSet="0"
@@ -194,7 +194,7 @@
194194
InlineFunctionExpansion="1"
195195
EnableIntrinsicFunctions="false"
196196
AdditionalIncludeDirectories=""
197-
PreprocessorDefinitions="_DEBUG;_CONSOLE"
197+
PreprocessorDefinitions="_CONSOLE"
198198
StringPooling="true"
199199
RuntimeLibrary="2"
200200
EnableFunctionLevelLinking="true"
@@ -243,7 +243,7 @@
243243
<Configuration
244244
Name="Debug|x64"
245245
ConfigurationType="1"
246-
InheritedPropertySheets=".\pyproject.vsprops;.\x64.vsprops"
246+
InheritedPropertySheets=".\pyproject.vsprops;.\x64.vsprops;.\debug.vsprops"
247247
>
248248
<Tool
249249
Name="VCPreBuildEventTool"
@@ -269,7 +269,7 @@
269269
Optimization="0"
270270
InlineFunctionExpansion="1"
271271
EnableIntrinsicFunctions="false"
272-
PreprocessorDefinitions="_DEBUG;_CONSOLE"
272+
PreprocessorDefinitions="_CONSOLE"
273273
/>
274274
<Tool
275275
Name="VCManagedResourceCompilerTool"

PCbuild9/pyd.vsprops

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
ProjectType="Visual C++"
44
Version="8.00"
55
Name="pyd"
6-
InheritedPropertySheets=".\pyproject.vsprops"
6+
InheritedPropertySheets=".\pyproject.vsprops;.\release.vsprops"
77
>
88
<Tool
99
Name="VCCLCompilerTool"
10-
PreprocessorDefinitions="NDEBUG"
1110
RuntimeLibrary="2"
1211
/>
1312
<Tool

PCbuild9/pyd_d.vsprops

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
ProjectType="Visual C++"
44
Version="8.00"
55
Name="pyd_d"
6-
InheritedPropertySheets=".\pyproject.vsprops"
6+
InheritedPropertySheets=".\pyproject.vsprops;.\debug.vsprops"
77
>
88
<Tool
99
Name="VCCLCompilerTool"
1010
Optimization="0"
1111
InlineFunctionExpansion="0"
1212
EnableIntrinsicFunctions="false"
13-
PreprocessorDefinitions="_DEBUG"
1413
RuntimeLibrary="3"
1514
/>
1615
<Tool

PCbuild9/pyproject.vsprops

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
InlineFunctionExpansion="1"
1313
EnableIntrinsicFunctions="true"
1414
AdditionalIncludeDirectories="..\Include; ..\PC"
15-
PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_DEPRECATE"
15+
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"
1616
StringPooling="true"
1717
ExceptionHandling="0"
1818
RuntimeLibrary="0"

0 commit comments

Comments
 (0)