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

Skip to content

Commit 431e71f

Browse files
Merge branch 'master' into disable-wchar-cache
2 parents 8750d48 + cc60cdd commit 431e71f

37 files changed

Lines changed: 550 additions & 337 deletions

Doc/howto/descriptor.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,9 @@ calls are unexciting::
372372
... print(x)
373373
... f = staticmethod(f)
374374
...
375-
>>> print(E.f(3))
375+
>>> E.f(3)
376376
3
377-
>>> print(E().f(3))
377+
>>> E().f(3)
378378
3
379379

380380
Using the non-data descriptor protocol, a pure Python version of

Include/cpython/pylifecycle.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ PyAPI_FUNC(int) Py_SetStandardStreamEncoding(const char *encoding,
1414

1515
/* PEP 432 Multi-phase initialization API (Private while provisional!) */
1616

17+
PyAPI_FUNC(_PyInitError) _Py_PreInitialize(void);
18+
PyAPI_FUNC(_PyInitError) _Py_PreInitializeFromPreConfig(
19+
_PyPreConfig *preconfig);
20+
1721
PyAPI_FUNC(_PyInitError) _Py_InitializeCore(
1822
PyInterpreterState **interp,
1923
const _PyCoreConfig *);

Include/cpython/unicodeobject.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,6 @@ PyAPI_FUNC(int) _PyUnicode_FormatAdvancedWriter(
734734
Py_ssize_t start,
735735
Py_ssize_t end);
736736

737-
PyAPI_FUNC(void) _Py_ReleaseInternedUnicodeStrings(void);
738-
739737
/* --- wchar_t support for platforms which support it --------------------- */
740738

741739
#ifdef HAVE_WCHAR_H

Include/internal/pycore_coreconfig.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,30 @@ extern "C" {
99
#endif
1010

1111

12+
/* --- _PyPreCmdline ------------------------------------------------- */
13+
14+
typedef struct {
15+
_PyWstrList argv;
16+
_PyWstrList xoptions; /* "-X value" option */
17+
int use_environment; /* -E option */
18+
int isolated; /* -I option */
19+
} _PyPreCmdline;
20+
21+
#define _PyPreCmdline_INIT \
22+
(_PyPreCmdline){ \
23+
.use_environment = -1, \
24+
.isolated = -1}
25+
/* Note: _PyPreCmdline_INIT sets other fields to 0/NULL */
26+
27+
PyAPI_FUNC(void) _PyPreCmdline_Clear(_PyPreCmdline *cmdline);
28+
PyAPI_FUNC(_PyInitError) _PyPreCmdline_Init(_PyPreCmdline *cmdline,
29+
const _PyArgv *args);
30+
PyAPI_FUNC(_PyInitError) _PyPreCmdline_Read(_PyPreCmdline *cmdline);
31+
PyAPI_FUNC(void) _PyPreCmdline_SetPreConfig(
32+
const _PyPreCmdline *cmdline,
33+
_PyPreConfig *config);
34+
35+
1236
/* --- _PyWstrList ------------------------------------------------ */
1337

1438
#ifndef NDEBUG

Include/internal/pycore_pathconfig.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ PyAPI_FUNC(_PyInitError) _PyPathConfig_SetGlobal(
4444
PyAPI_FUNC(_PyInitError) _PyPathConfig_Calculate_impl(
4545
_PyPathConfig *config,
4646
const _PyCoreConfig *core_config);
47-
PyAPI_FUNC(PyObject*) _PyPathConfig_ComputeArgv0(const _PyWstrList *argv);
47+
PyAPI_FUNC(int) _PyPathConfig_ComputeSysPath0(
48+
const _PyWstrList *argv,
49+
PyObject **path0);
4850
PyAPI_FUNC(int) _Py_FindEnvConfigValue(
4951
FILE *env_file,
5052
const wchar_t *key,

Include/internal/pycore_pystate.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,15 @@ struct _gilstate_runtime_state {
134134
/* Full Python runtime state */
135135

136136
typedef struct pyruntimestate {
137-
int initialized;
137+
/* Is Python pre-initialized? Set to 1 by _Py_PreInitialize() */
138+
int pre_initialized;
139+
140+
/* Is Python core initialized? Set to 1 by _Py_InitializeCore() */
138141
int core_initialized;
142+
143+
/* Is Python fully initialized? Set to 1 by Py_Initialize() */
144+
int initialized;
145+
139146
PyThreadState *finalizing;
140147

141148
struct pyinterpreters {
@@ -172,7 +179,8 @@ typedef struct pyruntimestate {
172179
// XXX Consolidate globals found via the check-c-globals script.
173180
} _PyRuntimeState;
174181

175-
#define _PyRuntimeState_INIT {.initialized = 0, .core_initialized = 0}
182+
#define _PyRuntimeState_INIT \
183+
{.pre_initialized = 0, .core_initialized = 0, .initialized = 0}
176184
/* Note: _PyRuntimeState_INIT sets other fields to 0/NULL */
177185

178186
PyAPI_DATA(_PyRuntimeState) _PyRuntime;
@@ -184,6 +192,8 @@ PyAPI_FUNC(void) _PyRuntimeState_ReInitThreads(void);
184192
Return NULL on success, or return an error message on failure. */
185193
PyAPI_FUNC(_PyInitError) _PyRuntime_Initialize(void);
186194

195+
PyAPI_FUNC(void) _PyRuntime_Finalize(void);
196+
187197
#define _Py_CURRENTLY_FINALIZING(tstate) \
188198
(_PyRuntime.finalizing == tstate)
189199

Lib/statistics.py

Lines changed: 48 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -766,74 +766,63 @@ def inv_cdf(self, p):
766766

767767
q = p - 0.5
768768
if fabs(q) <= 0.425:
769-
a0 = 3.38713_28727_96366_6080e+0
770-
a1 = 1.33141_66789_17843_7745e+2
771-
a2 = 1.97159_09503_06551_4427e+3
772-
a3 = 1.37316_93765_50946_1125e+4
773-
a4 = 4.59219_53931_54987_1457e+4
774-
a5 = 6.72657_70927_00870_0853e+4
775-
a6 = 3.34305_75583_58812_8105e+4
776-
a7 = 2.50908_09287_30122_6727e+3
777-
b1 = 4.23133_30701_60091_1252e+1
778-
b2 = 6.87187_00749_20579_0830e+2
779-
b3 = 5.39419_60214_24751_1077e+3
780-
b4 = 2.12137_94301_58659_5867e+4
781-
b5 = 3.93078_95800_09271_0610e+4
782-
b6 = 2.87290_85735_72194_2674e+4
783-
b7 = 5.22649_52788_52854_5610e+3
784769
r = 0.180625 - q * q
785-
num = (q * (((((((a7 * r + a6) * r + a5) * r + a4) * r + a3)
786-
* r + a2) * r + a1) * r + a0))
787-
den = ((((((((b7 * r + b6) * r + b5) * r + b4) * r + b3)
788-
* r + b2) * r + b1) * r + 1.0))
770+
num = (((((((2.50908_09287_30122_6727e+3 * r +
771+
3.34305_75583_58812_8105e+4) * r +
772+
6.72657_70927_00870_0853e+4) * r +
773+
4.59219_53931_54987_1457e+4) * r +
774+
1.37316_93765_50946_1125e+4) * r +
775+
1.97159_09503_06551_4427e+3) * r +
776+
1.33141_66789_17843_7745e+2) * r +
777+
3.38713_28727_96366_6080e+0) * q
778+
den = (((((((5.22649_52788_52854_5610e+3 * r +
779+
2.87290_85735_72194_2674e+4) * r +
780+
3.93078_95800_09271_0610e+4) * r +
781+
2.12137_94301_58659_5867e+4) * r +
782+
5.39419_60214_24751_1077e+3) * r +
783+
6.87187_00749_20579_0830e+2) * r +
784+
4.23133_30701_60091_1252e+1) * r +
785+
1.0)
789786
x = num / den
790787
return self.mu + (x * self.sigma)
791-
792788
r = p if q <= 0.0 else 1.0 - p
793789
r = sqrt(-log(r))
794790
if r <= 5.0:
795-
c0 = 1.42343_71107_49683_57734e+0
796-
c1 = 4.63033_78461_56545_29590e+0
797-
c2 = 5.76949_72214_60691_40550e+0
798-
c3 = 3.64784_83247_63204_60504e+0
799-
c4 = 1.27045_82524_52368_38258e+0
800-
c5 = 2.41780_72517_74506_11770e-1
801-
c6 = 2.27238_44989_26918_45833e-2
802-
c7 = 7.74545_01427_83414_07640e-4
803-
d1 = 2.05319_16266_37758_82187e+0
804-
d2 = 1.67638_48301_83803_84940e+0
805-
d3 = 6.89767_33498_51000_04550e-1
806-
d4 = 1.48103_97642_74800_74590e-1
807-
d5 = 1.51986_66563_61645_71966e-2
808-
d6 = 5.47593_80849_95344_94600e-4
809-
d7 = 1.05075_00716_44416_84324e-9
810791
r = r - 1.6
811-
num = ((((((((c7 * r + c6) * r + c5) * r + c4) * r + c3)
812-
* r + c2) * r + c1) * r + c0))
813-
den = ((((((((d7 * r + d6) * r + d5) * r + d4) * r + d3)
814-
* r + d2) * r + d1) * r + 1.0))
792+
num = (((((((7.74545_01427_83414_07640e-4 * r +
793+
2.27238_44989_26918_45833e-2) * r +
794+
2.41780_72517_74506_11770e-1) * r +
795+
1.27045_82524_52368_38258e+0) * r +
796+
3.64784_83247_63204_60504e+0) * r +
797+
5.76949_72214_60691_40550e+0) * r +
798+
4.63033_78461_56545_29590e+0) * r +
799+
1.42343_71107_49683_57734e+0)
800+
den = (((((((1.05075_00716_44416_84324e-9 * r +
801+
5.47593_80849_95344_94600e-4) * r +
802+
1.51986_66563_61645_71966e-2) * r +
803+
1.48103_97642_74800_74590e-1) * r +
804+
6.89767_33498_51000_04550e-1) * r +
805+
1.67638_48301_83803_84940e+0) * r +
806+
2.05319_16266_37758_82187e+0) * r +
807+
1.0)
815808
else:
816-
e0 = 6.65790_46435_01103_77720e+0
817-
e1 = 5.46378_49111_64114_36990e+0
818-
e2 = 1.78482_65399_17291_33580e+0
819-
e3 = 2.96560_57182_85048_91230e-1
820-
e4 = 2.65321_89526_57612_30930e-2
821-
e5 = 1.24266_09473_88078_43860e-3
822-
e6 = 2.71155_55687_43487_57815e-5
823-
e7 = 2.01033_43992_92288_13265e-7
824-
f1 = 5.99832_20655_58879_37690e-1
825-
f2 = 1.36929_88092_27358_05310e-1
826-
f3 = 1.48753_61290_85061_48525e-2
827-
f4 = 7.86869_13114_56132_59100e-4
828-
f5 = 1.84631_83175_10054_68180e-5
829-
f6 = 1.42151_17583_16445_88870e-7
830-
f7 = 2.04426_31033_89939_78564e-15
831809
r = r - 5.0
832-
num = ((((((((e7 * r + e6) * r + e5) * r + e4) * r + e3)
833-
* r + e2) * r + e1) * r + e0))
834-
den = ((((((((f7 * r + f6) * r + f5) * r + f4) * r + f3)
835-
* r + f2) * r + f1) * r + 1.0))
836-
810+
num = (((((((2.01033_43992_92288_13265e-7 * r +
811+
2.71155_55687_43487_57815e-5) * r +
812+
1.24266_09473_88078_43860e-3) * r +
813+
2.65321_89526_57612_30930e-2) * r +
814+
2.96560_57182_85048_91230e-1) * r +
815+
1.78482_65399_17291_33580e+0) * r +
816+
5.46378_49111_64114_36990e+0) * r +
817+
6.65790_46435_01103_77720e+0)
818+
den = (((((((2.04426_31033_89939_78564e-15 * r +
819+
1.42151_17583_16445_88870e-7) * r +
820+
1.84631_83175_10054_68180e-5) * r +
821+
7.86869_13114_56132_59100e-4) * r +
822+
1.48753_61290_85061_48525e-2) * r +
823+
1.36929_88092_27358_05310e-1) * r +
824+
5.99832_20655_58879_37690e-1) * r +
825+
1.0)
837826
x = num / den
838827
if q < 0.0:
839828
x = -x
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix leaks that led to build failure when configured with address sanitizer.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix leak in _PyRuntimeState_Fini. Contributed by Stéphane Wirtel.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
At Python initialization, the current directory is no longer prepended to
2+
:data:`sys.path` if it has been removed.

0 commit comments

Comments
 (0)