[issue8259] left shift operator doesn't accepts long as second argument

2010-03-29 Thread owirj

New submission from owirj :

python -V:
Python 2.6.5

Executing on 32-bit machine.

>From documentation ( http://docs.python.org/reference/expressions.html ), 
>"5.7. Shifting operations":
"These operators accept plain or long integers as arguments. The arguments are 
converted to a common type. They shift the first argument to the left or right 
by the number of bits given by the second argument."

In interpreter:
>>> x = 2677691728509L << 2147483648L
Traceback (most recent call last):
  File "", line 1, in 
OverflowError: long int too large to convert to int

hint: 2147483648 = (1 << 31)

First argument is long, second is long too, so expected behavior was normal 
execution. But as seen from the code above interpreter gives overflow error. 
Looks like he tries to convert second argument to int type, because this code 
works gracefully:
>>> x = 2677691728509L << 2147483647L

--
components: None
messages: 101887
nosy: owirj
severity: normal
status: open
title: left shift operator doesn't accepts long as second argument
versions: Python 2.6

___
Python tracker 
<http://bugs.python.org/issue8259>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8259] left shift operator doesn't accepts long as second argument

2010-03-29 Thread owirj

owirj  added the comment:

Antoine Pitrou:
The reason you get an OverflowError in 32-bit mode is that 2**31 is too large 
to be represented as a (signed) C long, rather than unsigned.

I understand that, but after reading documentation, was expecting it to convert 
second argument to long type, which is not concerned with architecture 
dependant implementation of int.

--

___
Python tracker 
<http://bugs.python.org/issue8259>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com