Commit 89427cd
bpo-32417: Make timedelta arithmetic respect subclasses (python#10902)
* Make timedelta return subclass types
Previously timedelta would always return the `date` and `datetime`
types, regardless of what it is added to. This makes it return
an object of the type it was added to.
* Add tests for timedelta arithmetic on subclasses
* Make pure python timedelta return subclass types
* Add test for fromtimestamp with tz argument
* Add tests for subclass behavior in now
* Add news entry.
Fixes:
bpo-32417
bpo-35364
* More descriptive variable names in tests
Addresses Victor's comments1 parent ca7d293 commit 89427cd
File tree
4 files changed
+90
-19
lines changed- Lib
- test
- Misc/NEWS.d/next/Library
- Modules
4 files changed
+90
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1014 | 1014 | | |
1015 | 1015 | | |
1016 | 1016 | | |
1017 | | - | |
| 1017 | + | |
1018 | 1018 | | |
1019 | 1019 | | |
1020 | 1020 | | |
| |||
2024 | 2024 | | |
2025 | 2025 | | |
2026 | 2026 | | |
2027 | | - | |
2028 | | - | |
2029 | | - | |
2030 | | - | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
2031 | 2031 | | |
2032 | 2032 | | |
2033 | 2033 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
820 | 820 | | |
821 | 821 | | |
822 | 822 | | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
823 | 861 | | |
824 | 862 | | |
825 | 863 | | |
| |||
2604 | 2642 | | |
2605 | 2643 | | |
2606 | 2644 | | |
2607 | | - | |
| 2645 | + | |
2608 | 2646 | | |
2609 | | - | |
2610 | | - | |
2611 | | - | |
2612 | | - | |
2613 | | - | |
| 2647 | + | |
| 2648 | + | |
| 2649 | + | |
| 2650 | + | |
| 2651 | + | |
| 2652 | + | |
2614 | 2653 | | |
2615 | 2654 | | |
2616 | | - | |
| 2655 | + | |
2617 | 2656 | | |
2618 | 2657 | | |
2619 | 2658 | | |
2620 | 2659 | | |
2621 | | - | |
| 2660 | + | |
2622 | 2661 | | |
2623 | | - | |
| 2662 | + | |
2624 | 2663 | | |
2625 | 2664 | | |
2626 | 2665 | | |
2627 | 2666 | | |
2628 | 2667 | | |
2629 | | - | |
| 2668 | + | |
2630 | 2669 | | |
2631 | 2670 | | |
2632 | 2671 | | |
2633 | 2672 | | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
| 2684 | + | |
| 2685 | + | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + | |
2634 | 2697 | | |
2635 | 2698 | | |
2636 | 2699 | | |
| |||
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 | |
|---|---|---|---|
| |||
3004 | 3004 | | |
3005 | 3005 | | |
3006 | 3006 | | |
3007 | | - | |
| 3007 | + | |
| 3008 | + | |
3008 | 3009 | | |
3009 | 3010 | | |
3010 | 3011 | | |
| |||
5166 | 5167 | | |
5167 | 5168 | | |
5168 | 5169 | | |
5169 | | - | |
5170 | | - | |
5171 | | - | |
| 5170 | + | |
| 5171 | + | |
| 5172 | + | |
| 5173 | + | |
5172 | 5174 | | |
5173 | 5175 | | |
5174 | 5176 | | |
| |||
0 commit comments