Skip to content

Instantly share code, notes, and snippets.

@zzzeek
Created January 30, 2013 00:01
Show Gist options
  • Select an option

  • Save zzzeek/4669240 to your computer and use it in GitHub Desktop.

Select an option

Save zzzeek/4669240 to your computer and use it in GitHub Desktop.
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import division
>>> 1 / 2
0.5
>>> import pdb
>>> pdb.set_trace()
--Return--
> <stdin>(1)<module>()->None
(Pdb) 1/2
0
(Pdb)
@ncoghlan
Copy link

The problem is that the flag isn't in effect for the code that actually creates pdb's eval loop. You can see a similar effect here, where the function is compiled before we set the flag, so it doesn't see the change and continues with the old behaviour:

>>> def f(code):
...     return eval(code)
... 
>>> from __future__ import division
>>> eval("1/2")
0.5
>>> f("1/2")
0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment