mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
Fix segfault when doing string formatting on subclasses of long if
__oct__, __hex__ don't return a string. Klocwork 308
This commit is contained in:
parent
3cb31ac704
commit
56423e5762
3 changed files with 14 additions and 1 deletions
|
|
@ -230,6 +230,14 @@ test_exc(u'no format', '1', TypeError,
|
|||
test_exc(u'no format', u'1', TypeError,
|
||||
"not all arguments converted during string formatting")
|
||||
|
||||
class Foobar(long):
|
||||
def __oct__(self):
|
||||
# Returning a non-string should not blow up.
|
||||
return self + 1
|
||||
|
||||
test_exc('%o', Foobar(), TypeError,
|
||||
"expected string or Unicode object, long found")
|
||||
|
||||
if sys.maxint == 2**31-1:
|
||||
# crashes 2.2.1 and earlier:
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue