Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unused number magic methods leaked into Py2.6 #46260

Closed
rhettinger opened this issue Jan 29, 2008 · 5 comments
Closed

Unused number magic methods leaked into Py2.6 #46260

rhettinger opened this issue Jan 29, 2008 · 5 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@rhettinger
Copy link
Contributor

BPO 1968
Nosy @rhettinger

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2008-01-31.17:46:17.151>
created_at = <Date 2008-01-29.22:55:44.958>
labels = ['type-bug', 'library']
title = 'Unused number magic methods leaked into Py2.6'
updated_at = <Date 2008-01-31.17:46:17.150>
user = 'https://github.com/rhettinger'

bugs.python.org fields:

activity = <Date 2008-01-31.17:46:17.150>
actor = 'jyasskin'
assignee = 'jyasskin'
closed = True
closed_date = <Date 2008-01-31.17:46:17.151>
closer = 'jyasskin'
components = ['Library (Lib)']
creation = <Date 2008-01-29.22:55:44.958>
creator = 'rhettinger'
dependencies = []
files = []
hgrepos = []
issue_num = 1968
keywords = []
message_count = 5.0
messages = ['61835', '61841', '61842', '61843', '61916']
nosy_count = 2.0
nosy_names = ['rhettinger', 'jyasskin']
pr_nums = []
priority = 'high'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue1968'
versions = ['Python 2.6']

@rhettinger
Copy link
Contributor Author

The Py2.6 code has __round__, __ceil__, and __floor__ methods still in
several objects (int, longs, float, Rational) but they are not invoked
by anything. For example, round(Rational(22,7)) does not use the
Rational.__round__ code and round(22) does not use the code for
int.__round__; the code is just ignored. Since the code is not used, it
probably shouldn't be in Py2.6.

I think these backports happened before Guido decided, "I think the
pre-3.0 rule should be: round(), math.floor(), math.ceil()
*always* return a float." Probably, rev 59731 may have intended to
revert these changes but just missed them. IIRC, the decision was that
only __trunc__ would be backported and the other three magic methods
would wait for Py3.0 where their invocation functions would get their
new signature and start calling the magic methods.

@jyasskin
Copy link
Mannequin

jyasskin mannequin commented Jan 30, 2008

I can't find the __round__, __ceil__, and __floor__ methods in int,
long, and float. I left them in Rational on purpose, thinking that there
might be a module that provided the new behaviors for 2.6 code, but
you're probably right that these should be rolled back until such a
module appears. They do have the benefit of demonstrating that it's
possible to write a numeric class that does the right thing in both 2.6
and 3.0 without many code changes. (I should check that 2to3 does the
right thing on it.)

@rhettinger
Copy link
Contributor Author

For 2.6, they should be omitted from rational.py. The code that is
there is not the code that is run -- that impairs its value as a demo
module.

@jyasskin
Copy link
Mannequin

jyasskin mannequin commented Jan 30, 2008

Will do.

@jyasskin jyasskin mannequin added the stdlib Python modules in the Lib dir label Jan 30, 2008
@tiran tiran added the type-bug An unexpected behavior, bug, or error label Jan 30, 2008
@jyasskin
Copy link
Mannequin

jyasskin mannequin commented Jan 31, 2008

Done in r60480.

@jyasskin jyasskin mannequin closed this as completed Jan 31, 2008
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants