[issue21546] int('\0') gives wrong error message

2014-05-23 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
resolution:  - duplicate
stage:  - resolved
status: open - closed
superseder:  - `int()`, `float()`, etc think python strings are null-terminated
type:  - behavior

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21546
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21546] int('\0') gives wrong error message

2014-05-20 Thread Kurt Rose

New submission from Kurt Rose:

int() ignores everything after a null byte when reporting an error message.

Here you can see an example of how this manifests, and why could be a problem.

Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit(Intel)] on 
win32
Type help, copyright, credits or license for more information.
 int('a')
Traceback (most recent call last):
  File stdin, line 1, in module
ValueError: invalid literal for int() with base 10: 'a'
 int('\0a')
Traceback (most recent call last):
  File stdin, line 1, in module
ValueError: invalid literal for int() with base 10: ''
 int('abc\0def')
Traceback (most recent call last):
  File stdin, line 1, in module
ValueError: invalid literal for int() with base 10: 'abc'

--
components: Interpreter Core
messages: 218859
nosy: Kurt.Rose
priority: normal
severity: normal
status: open
title: int('\0') gives wrong error message
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21546
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21546] int('\0') gives wrong error message

2014-05-20 Thread STINNER Victor

STINNER Victor added the comment:

It looks like the issue was already fixed in Python 3:

Python 3.5.0a0 (default:61d9aa8be445, May 20 2014, 16:03:51) 
 int('a')
Traceback (most recent call last):
  File stdin, line 1, in module
ValueError: invalid literal for int() with base 10: 'a'
 int('\0a')
Traceback (most recent call last):
  File stdin, line 1, in module
ValueError: invalid literal for int() with base 10: '\x00a'
 int('abc\x00def')
Traceback (most recent call last):
  File stdin, line 1, in module
ValueError: invalid literal for int() with base 10: 'abc\x00def'

And the last one:

 int('\0')
Traceback (most recent call last):
  File stdin, line 1, in module
ValueError: invalid literal for int() with base 10: '\x00'

--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21546
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21546] int('\0') gives wrong error message

2014-05-20 Thread eryksun

eryksun added the comment:

See issue 16741. This is fixed in 3.3, but 2.7 intentionally keeps the old 
behavior.

--
nosy: +eryksun

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21546
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com