This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: In getargs.c, make 'L' code raise TypeError for float arguments.
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: mark.dickinson Nosy List: mark.dickinson, vstinner
Priority: normal Keywords: patch

Created on 2010-06-08 21:42 by mark.dickinson, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue8950.diff mark.dickinson, 2010-06-09 12:23
Messages (5)
msg107352 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-06-08 21:42
Currently all but one of the integer format codes for getargs.c raise TypeError when passed a float.  The 'L' code produces a warning rather than raising an error.

This was deliberate at the time, because all except the 'L' code already raised a DeprecationWarning in Python 3.1, and were converted to raise TypeError for 3.2.  Since the 'L' code didn't raise a warning for float inputs in 3.1, directly raising a TypeError in 3.2 seemed a bit abrupt.

However, I'd like to revisit this decision, and make the 'L' code raise a TypeError in 3.2.  Note that

(1) The 'L' code represents the Py_LONG_LONG type, and isn't used very much;  I think the risk of unexpected breakage from this change is fairly small.

(2) One of the places that the 'L' code *is* used is when parsing strange C types (like off_t) that are matched with either size_t, long or long long at configure + build time.  So one platform might end up parsing off_t types with the 'n' code, while another parses them with the 'L' code.  It would be desirable for both platforms to have the same behaviour when passed a float.

Any objections to making this change?

See also issue 5080.
msg107354 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-06-08 21:57
> One of the places that the 'L' code *is* used is when parsing
> strange C types (like off_t)

It has unexepected consequences. Example:

   >>> x=open("x", "w")
   >>> x.seek(0.0)
   0.0
   >>> x.seek(-0.0)
   -0.0
   >>> x.seek(0.1)
   0.1
   >>> x.tell()
   0

I think that we should just raise an error in Python 3.2 because I consider this as a bug. It remembers me another bug related to file and float: http://bugs.python.org/issue5080#msg92400
msg107392 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-06-09 12:23
Here's a patch.  Victor, are you interested in reviewing?
msg107395 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-06-09 12:35
Le mercredi 09 juin 2010 14:24:01, vous avez écrit :
> Here's a patch.  Victor, are you interested in reviewing?

I ran the whole test suite: there is no error. The patch is ok, please commit 
it in Python 3.2.
msg107461 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-06-10 16:05
Committed, r81873.  Thanks for reviewing, Victor.
History
Date User Action Args
2022-04-11 14:57:02adminsetgithub: 53196
2010-06-10 19:02:01mark.dickinsonsetstatus: open -> closed
resolution: fixed
stage: resolved
2010-06-10 16:05:43mark.dickinsonsetmessages: + msg107461
2010-06-09 12:35:34vstinnersetmessages: + msg107395
2010-06-09 12:23:51mark.dickinsonsetfiles: + issue8950.diff
keywords: + patch
messages: + msg107392
2010-06-08 21:57:41vstinnersetmessages: + msg107354
2010-06-08 21:42:46mark.dickinsoncreate