New submission from Serhiy Storchaka:

PEP 461 says that all numeric bytes formatting codes will work as they do for 
str. In particular b"%x" % val is equivalent to ("%x" % val).encode("ascii"). 
But this is wrong with current implementation:

>>> '%x' % 3.14
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: %x format: an integer is required, not float
>>> b'%x' % 3.14
b'3'

The same is for %X, %o and %c.

Raising TypeError on non-integer input to %c, %o, %x, and %X was added in 
issue19995.

----------
components: Interpreter Core
messages: 236056
nosy: ethan.furman, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Inconsistency between str and bytes formatting of integers
type: behavior
versions: Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23466>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to