1.1 --- a/lib/operator/unary.py Fri Jan 25 23:12:44 2019 +0100
1.2 +++ b/lib/operator/unary.py Fri Jan 25 23:24:33 2019 +0100
1.3 @@ -3,7 +3,8 @@
1.4 """
1.5 Operator support.
1.6
1.7 -Copyright (C) 2010, 2013, 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2010, 2013, 2015, 2016, 2017,
1.9 + 2019 Paul Boddie <paul@boddie.org.uk>
1.10
1.11 This program is free software; you can redistribute it and/or modify it under
1.12 the terms of the GNU General Public License as published by the Free Software
1.13 @@ -20,7 +21,7 @@
1.14 """
1.15
1.16 from operator.core import unary_op
1.17 -from native.int import int_neg, int_not, is_int
1.18 +from native import int_neg, int_not, is_int, float_neg
1.19
1.20 # These functions defer method lookup by wrapping the attribute access in
1.21 # lambda functions. Thus, the appropriate methods are defined locally, but no
1.22 @@ -34,6 +35,8 @@
1.23 def neg(a):
1.24 if is_int(a):
1.25 return int_neg(a)
1.26 + elif a.__class__ is float:
1.27 + return float_neg(a)
1.28 return unary_op(a, lambda a: a.__neg__)
1.29
1.30 def not_(a):
1.31 @@ -42,7 +45,7 @@
1.32 return not a
1.33
1.34 def pos(a):
1.35 - if is_int(a):
1.36 + if is_int(a) or a.__class__ is float:
1.37 return a
1.38 return unary_op(a, lambda a: a.__pos__)
1.39