Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdc68f31

Browse files
committed
address review
1 parent1f70836 commitdc68f31

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

‎Lib/fractions.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,8 @@ def __pow__(a, b, modulo=None):
856856
result will be rational.
857857
858858
"""
859+
ifmoduloisnotNone:
860+
returnNotImplemented
859861
ifisinstance(b,numbers.Rational):
860862
ifb.denominator==1:
861863
power=b.numerator
@@ -877,8 +879,6 @@ def __pow__(a, b, modulo=None):
877879
result=float(a)**float(b)
878880
else:
879881
result=float(a)**b
880-
ifmoduloisnotNone:
881-
result%=modulo
882882
returnresult
883883

884884
def__rpow__(b,a):

‎Lib/test/test_fractions.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,10 @@ def test_complex_handling(self):
16341634
divmod,b,a)
16351635

16361636
deftest_three_argument_pow(self):
1637-
self.assertTypedEquals(pow(F(3),4,5),F(1))
1637+
message="unsupported operand type(s) for ** or pow(): '%s', '%s', '%s'"
1638+
self.assertRaisesMessage(TypeError,
1639+
message% ("Fraction","int","int"),
1640+
pow,F(3),4,5)
16381641

16391642

16401643
if__name__=='__main__':
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
fractions.Fraction.__pow__accept optional modulo argument.
1+
Fraction.__pow__accepts (but does not implement) optional modulo argument.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp