New submission from Lisandro Dalcin <dalc...@gmail.com>:

At Objects/longobject.c, in almost all cases
OverflowError is raised when a unsigned integral is requested from a
negative PyLong. However, this one breaks the rules:

int
_PyLong_AsByteArray(PyLongObject* v,
                  unsigned char* bytes, size_t n,
                  int little_endian, int is_signed)
{
<...>
              if (!is_signed) {
                      PyErr_SetString(PyExc_TypeError,
                              "can't convert negative long to 
unsigned");
                      return -1;
              }
<...>
}

----------
components: Interpreter Core
messages: 81316
nosy: dalcinl
severity: normal
status: open
title: negative PyLong -> C unsigned integral, TypeError or OverflowError?
type: behavior
versions: Python 2.7

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

Reply via email to