Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #101879

Re: When is an int not an int? Who can explain this?

From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: When is an int not an int? Who can explain this?
Date 2016-01-19 03:51 +1100
Message-ID <mailman.90.1453135892.15297.python-list@python.org> (permalink)
References <n7j2r0$hc4$1@dont-email.me> <mailman.89.1453134008.15297.python-list@python.org> <n7j3s1$hc4$2@dont-email.me>

Show all headers | View raw


On Tue, Jan 19, 2016 at 3:28 AM, Charles T. Smith
<cts.private.yahoo@gmail.com> wrote:
> On Tue, 19 Jan 2016 03:19:59 +1100, Chris Angelico wrote:
>> Possibility #1: 'int' has been rebound.
>>
>> Possibility #2: 'type' has been rebound.
>>
>> I'd check them in that order.
>>
>> ChrisA
>
>
> But:
>
> (PDB)p 5 + 0
> 5

That shows that your literals haven't changed. They basically never
will (barring *really* crazy shenanigans).

> (PDB)class c (object): pass
> (PDB)type (c()) is c
> True

And this shows that the name 'type' probably hasn't changed. It's
still possible that it's not the normal 'type' type, but far more
likely that it's 'int' that got rebound, which is why I suggested
checking for that first.

> Okay, I think I understand it now:
>
> (PDB)type (int)
> <type 'module'>
>
> (PDB)type (float)
> <type 'type'>

And that's pretty strong evidence right there! So the next question
is... what got imported under the name 'int'?

int.__name__ will be a start. If that just returns the string 'int',
then try int.__package__ which might give a hint. Also, int.__file__
will tell you where it was loaded from, if it was indeed loaded from a
file.

Armed with that information, you should be able to track down what's
going on. It's curious, though, that you have a callable subclass of
module bound to the name int. Very curious indeed.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

When is an int not an int?  Who can explain this? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-01-18 16:11 +0000
  Re: When is an int not an int? Who can explain this? Chris Angelico <rosuav@gmail.com> - 2016-01-19 03:19 +1100
    Re: When is an int not an int? Who can explain this? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-01-18 16:28 +0000
      Re: When is an int not an int? Who can explain this? Chris Angelico <rosuav@gmail.com> - 2016-01-19 03:51 +1100
      Re: When is an int not an int? Who can explain this? Ian Kelly <ian.g.kelly@gmail.com> - 2016-01-18 10:00 -0700
      Re: When is an int not an int? Who can explain this? Random832 <random832@fastmail.com> - 2016-01-18 12:02 -0500
      Re: When is an int not an int? Who can explain this? Chris Angelico <rosuav@gmail.com> - 2016-01-19 04:35 +1100

csiph-web