Commit d929f18
authored
bpo-36443, bpo-36202: Since Python 3.7.0, calling Py_DecodeLocale()
before Py_Initialize() produces mojibake if the LC_CTYPE locale is
coerced and/or if the UTF-8 Mode is enabled by the user
configuration. This change fix the issue by disabling LC_CTYPE
coercion and UTF-8 Mode by default. They must now be enabled
explicitly (opt-in) using the new _Py_PreInitialize() API with
_PyPreConfig.
When embedding Python, set coerce_c_locale and utf8_mode attributes
of _PyPreConfig to -1 to enable automatically these parameters
depending on the LC_CTYPE locale, environment variables and command
line arguments
Alternative: Setting Py_UTF8Mode to 1 always explicitly enables the
UTF-8 Mode.
Changes:
* _PyPreConfig_INIT now sets coerce_c_locale and utf8_mode to 0 by
default.
* _Py_InitializeFromArgs() and _Py_InitializeFromWideArgs() can now
be called with config=NULL.
1 parent 4a9a505 commit d929f18
File tree
7 files changed
+58
-46
lines changed- Include/cpython
- Lib/test
- Misc/NEWS.d/next/C API
- Modules
- Programs
- Python
7 files changed
+58
-46
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
71 | 74 | | |
72 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
73 | 80 | | |
74 | 81 | | |
75 | 82 | | |
| |||
83 | 90 | | |
84 | 91 | | |
85 | 92 | | |
86 | | - | |
87 | | - | |
88 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
89 | 104 | | |
90 | 105 | | |
91 | 106 | | |
| |||
104 | 119 | | |
105 | 120 | | |
106 | 121 | | |
107 | | - | |
108 | | - | |
109 | 122 | | |
110 | 123 | | |
111 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
494 | 494 | | |
495 | 495 | | |
496 | 496 | | |
497 | | - | |
498 | 497 | | |
| 498 | + | |
499 | 499 | | |
500 | 500 | | |
501 | 501 | | |
| |||
573 | 573 | | |
574 | 574 | | |
575 | 575 | | |
576 | | - | |
577 | 576 | | |
578 | 577 | | |
579 | 578 | | |
580 | 579 | | |
581 | 580 | | |
582 | 581 | | |
583 | 582 | | |
584 | | - | |
585 | | - | |
586 | 583 | | |
587 | 584 | | |
588 | 585 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
57 | 60 | | |
58 | | - | |
| 61 | + | |
| 62 | + | |
59 | 63 | | |
60 | 64 | | |
61 | | - | |
| 65 | + | |
| 66 | + | |
62 | 67 | | |
63 | 68 | | |
64 | 69 | | |
65 | 70 | | |
66 | 71 | | |
| 72 | + | |
| 73 | + | |
67 | 74 | | |
68 | | - | |
| 75 | + | |
69 | 76 | | |
70 | 77 | | |
71 | | - | |
| 78 | + | |
72 | 79 | | |
73 | 80 | | |
74 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | | - | |
445 | | - | |
446 | 444 | | |
447 | 445 | | |
448 | 446 | | |
| |||
617 | 615 | | |
618 | 616 | | |
619 | 617 | | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | 618 | | |
632 | 619 | | |
633 | 620 | | |
| |||
654 | 641 | | |
655 | 642 | | |
656 | 643 | | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | 644 | | |
662 | 645 | | |
663 | 646 | | |
| |||
685 | 668 | | |
686 | 669 | | |
687 | 670 | | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | 671 | | |
693 | 672 | | |
694 | 673 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
389 | | - | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
390 | 392 | | |
391 | 393 | | |
392 | 394 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
485 | 485 | | |
486 | 486 | | |
487 | 487 | | |
488 | | - | |
| 488 | + | |
489 | 489 | | |
490 | 490 | | |
491 | 491 | | |
| |||
548 | 548 | | |
549 | 549 | | |
550 | 550 | | |
551 | | - | |
| 551 | + | |
552 | 552 | | |
553 | 553 | | |
554 | 554 | | |
| |||
785 | 785 | | |
786 | 786 | | |
787 | 787 | | |
| 788 | + | |
788 | 789 | | |
789 | 790 | | |
790 | 791 | | |
| |||
799 | 800 | | |
800 | 801 | | |
801 | 802 | | |
802 | | - | |
803 | | - | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
804 | 807 | | |
805 | 808 | | |
806 | 809 | | |
| |||
839 | 842 | | |
840 | 843 | | |
841 | 844 | | |
842 | | - | |
| 845 | + | |
843 | 846 | | |
844 | | - | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
845 | 853 | | |
846 | 854 | | |
847 | 855 | | |
| |||
1395 | 1403 | | |
1396 | 1404 | | |
1397 | 1405 | | |
1398 | | - | |
| 1406 | + | |
1399 | 1407 | | |
1400 | 1408 | | |
1401 | 1409 | | |
| |||
0 commit comments