<br><br><div class="gmail_quote">On Sat, Nov 7, 2009 at 11:34 PM, Brian Granger <span dir="ltr"><<a href="http://ellisonbg.net">ellisonbg.net</a>@<a href="http://gmail.com">gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
He he. The good news is that trunk fixes most of this...<br><br>In [2]: __builtins__.True = False<br><br>In [3]: __builtins__.True == False<br>Out[3]: True<br><br>But exiting doesn't work:<br><br>In [4]: Exit<br><br>
In [5]: <br>
<br>The reason exiting doesn't work is that ask_exit is called by Exit, exit() and quit():<br><br> def ask_exit(self):<br> """ Call for exiting. Can be overiden and used as a callback. """<br>
self.exit_now = True<br><br>But if True is False, self.exit_now won't trigger the exit.<br><br>The funny thing is that doing the opposite really screws things up:<br><br>In [1]: __builtins__.False = True<br> ...: <br>
...: <br> ...: <br> ...: <br> ...: # stuck forever indented...<br><br>But, just because you can hit your head with a hammer, doesn't mean you should...;-)<br><br>Cheers,<br><br>Brian<br><br><br></blockquote>
<div><br>Good morning :)<br><br>How do you fix these in the trunk? Raising an exception if a user enters any of the forbidden assignments ?<br><br>Fortunately not many out who has the obsession of defining True as False. Somewhat I connect this to Wittgenstein's belief that "There are no philosophical questions, but only language puzzles."<br>
<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br><div class="gmail_quote"><div><div></div><div class="h5">
On Sat, Nov 7, 2009 at 8:56 PM, Gökhan Sever <span dir="ltr"><<a href="mailto:gokhansever@gmail.com" target="_blank">gokhansever@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">
Hello,<br><br>After reading the "Breaking the Universe in Python 2.6" section (Pg. 414) in Mark Lutz's Learning Python 4th Edition. Two issues appeared as shown below:<br><b><br>1-) If I start ipython -pylab the mentioned assignment completely blocks the session. Only stopping or killing the process ends the current session.</b><br>
<br>[gsever@ccn Desktop]$ ipython -pylab<br> Logging to /home/gsever/.ipython/2009-11-07.py<br><br>Python 2.6 (r26:66714, Jun 8 2009, 16:07:26) <br>Type "copyright", "credits" or "license" for more information.<br>
<br>IPython 0.10 -- An enhanced Interactive Python.<br>? -> Introduction and overview of IPython's features.<br>%quickref -> Quick reference.<br>help -> Python's own help system.<br>object? -> Details about 'object'. ?object also works, ?? prints more.<br>
<br> Welcome to pylab, a matplotlib-based Python environment.<br> For more information, type 'help(pylab)'.<br><br>I[1]: __builtins__.True = False<br>Exception in thread Thread-1:<br>Traceback (most recent call last):<br>
File "/usr/lib/python2.6/threading.py", line 522, in __bootstrap_inner<br> self.run()<br> File "/home/gsever/Desktop/python-repo/ipython/IPython/Shell.py", line 760, in run<br> self.IP.mainloop(self._banner)<br>
File "/home/gsever/Desktop/python-repo/ipython/IPython/iplib.py", line 1760, in mainloop<br> self.interact(banner)<br> File "/home/gsever/Desktop/python-repo/ipython/IPython/iplib.py", line 1998, in interact<br>
more = self.push(line)<br> File "/home/gsever/Desktop/python-repo/ipython/IPython/iplib.py", line 2302, in push<br> more = self.runsource('\n'.join(self.buffer), self.filename)<br> File "/home/gsever/Desktop/python-repo/ipython/IPython/Shell.py", line 431, in runsource<br>
completed_ev.wait()<br> File "/usr/lib/python2.6/threading.py", line 393, in wait<br> self.__cond.wait(timeout)<br> File "/usr/lib/python2.6/threading.py", line 230, in wait<br> raise RuntimeError("cannot wait on un-aquired lock")<br>
RuntimeError: cannot wait on un-aquired lock<br><br>Unhandled exception in thread started by <bound method IPShellMatplotlibQt4.__bootstrap of <IPShellMatplotlibQt4(Thread-1, started -1230734480)>><br>---------------------------------------------------------------------------<br>
RuntimeError Traceback (most recent call last)<br><br>/usr/lib/python2.6/threading.pyc in __bootstrap(self)<br> 495 # if a non-daemonic encounters this, something else is wrong.<br>
<br> 496 try:<br>--> 497 self.__bootstrap_inner()<br> 498 except:<br> 499 if self.__daemonic and _sys is None:<br><br>/usr/lib/python2.6/threading.pyc in __bootstrap_inner(self)<br>
568 finally:<br> 569 with _active_limbo_lock:<br>--> 570 self.__stop()<br> 571 try:<br> 572 # We don't call self.__delete() because it also<br>
<br><br>/usr/lib/python2.6/threading.pyc in __stop(self)<br> 579 self.__block.acquire()<br> 580 self.__stopped = True<br>--> 581 self.__block.notify_all()<br> 582 self.__block.release()<br>
583 <br><br>/usr/lib/python2.6/threading.pyc in notifyAll(self)<br> 287 <br> 288 def notifyAll(self):<br>--> 289 self.notify(len(self.__waiters))<br> 290 <br> 291 notify_all = notifyAll<br>
<br>/usr/lib/python2.6/threading.pyc in notify(self, n)<br> 270 def notify(self, n=1):<br> 271 if not self._is_owned():<br>--> 272 raise RuntimeError("cannot notify on un-aquired lock")<br>
273 __waiters = self.__waiters<br> 274 waiters = __waiters[:n]<br><br>RuntimeError: cannot notify on un-aquired lock---------------------------------------------------------------------------<br>RuntimeError Traceback (most recent call last)<br>
<br>/home/gsever/Desktop/python-repo/ipython/IPython/Shell.pyc in on_timer(self)<br> 1075 def on_timer(self):<br> 1076 update_tk(<a href="http://self.tk" target="_blank">self.tk</a>)<br>-> 1077 result = self.IP.runcode()<br>
1078 self.timer.start(self.TIMEOUT)<br> 1079 return result<br><br>/home/gsever/Desktop/python-repo/ipython/IPython/Shell.pyc in runcode(self)<br> 491 CODE_RUN = False<br> 492 # allow runsource() return from wait<br>
<br>--> 493 completed_ev.set()<br> 494 <br> 495 <br><br>/usr/lib/python2.6/threading.pyc in set(self)<br> 376 try:<br> 377 self.__flag = True<br>--> 378 self.__cond.notify_all()<br>
379 finally:<br> 380 self.__cond.release()<br><br>/usr/lib/python2.6/threading.pyc in notifyAll(self)<br> 287 <br> 288 def notifyAll(self):<br>--> 289 self.notify(len(self.__waiters))<br>
290 <br> 291 notify_all = notifyAll<br><br>/usr/lib/python2.6/threading.pyc in notify(self, n)<br> 270 def notify(self, n=1):<br> 271 if not self._is_owned():<br>--> 272 raise RuntimeError("cannot notify on un-aquired lock")<br>
273 __waiters = self.__waiters<br> 274 waiters = __waiters[:n]<br><br>RuntimeError: cannot notify on un-aquired lock<br><br><b><br>2-) Testing just with regular ipython. This time it gets even more bizarre. </b><br>
<br>In[1] It lets to do the assignment.<br>In[2] A simple calculation results ok<br>In[3] Tab-completion is blocked<br>In[4] ? cannot retrieve the documentation<br>In[5] exit() doesn't leave the session<br><br>[gsever@ccn Desktop]$ ipython<br>
Logging to /home/gsever/.ipython/2009-11-07.py<br><br>Python 2.6 (r26:66714, Jun 8 2009, 16:07:26) <br>Type "copyright", "credits" or "license" for more information.<br><br>IPython 0.10 -- An enhanced Interactive Python.<br>
? -> Introduction and overview of IPython's features.<br>%quickref -> Quick reference.<br>help -> Python's own help system.<br>object? -> Details about 'object'. ?object also works, ?? prints more.<br>
<br>I[1]: __builtins__.True = False<br><br>I[2]: 2*5<br>O[2]: 10<br><br>I[3]: import a<br>---------------------------------------------------------------------------<br>ImportError Traceback (most recent call last)<br>
<br>/home/gsever/Desktop/<ipython console> in <module>()<br><br>ImportError: No module named a<br><br>I[4]: __builtins__.?<br>---------------------------------------------------------------------------<br>KeyError Traceback (most recent call last)<br>
<br>/home/gsever/Desktop/python-repo/ipython/IPython/iplib.pyc in multiline_prefilter(self, line, continue_prompt)<br> 2456 out = []<br> 2457 for l in line.rstrip('\n').split('\n'):<br>
-> 2458 out.append(self._prefilter(l, continue_prompt))<br> 2459 return '\n'.join(out)<br> 2460 <br><br>/home/gsever/Desktop/python-repo/ipython/IPython/iplib.pyc in _prefilter(self, line, continue_prompt)<br>
2438 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg<br><br> 2439 <br>-> 2440 return prefilter.prefilter(line_info, self)<br> 2441 <br> 2442 <br><br>
/home/gsever/Desktop/python-repo/ipython/IPython/prefilter.pyc in prefilter(line_info, ip)<br> 149 handler = check(line_info, ip)<br> 150 if handler:<br>--> 151 return handler(line_info)<br>
152 <br> 153 return ip.handle_normal(line_info)<br><br>/home/gsever/Desktop/python-repo/ipython/IPython/iplib.pyc in handle_help(self, line_info)<br> 2627 if line:<br> 2628 #print 'line:<%r>' % line # dbg<br>
<br>-> 2629 self.magic_pinfo(line)<br> 2630 else:<br> 2631 page(self.usage,screen_lines=self.rc.screen_length)<br><br>/home/gsever/Desktop/python-repo/ipython/IPython/Magic.pyc in magic_pinfo(self, parameter_s, namespaces)<br>
658 else:<br> 659 self._inspect('pinfo', oname, detail_level=detail_level,<br><br>*** ERROR: EOF in multi-line statement<br><br>--> 660 namespaces=namespaces)<br>
<br>*** ERROR: EOF in multi-line statement<br><br> 661 <br> 662 def magic_pdef(self, parameter_s='', namespaces=None):<br><br>/home/gsever/Desktop/python-repo/ipython/IPython/Magic.pyc in _inspect(self, meth, oname, namespaces, **kw)<br>
714 return 'not found'<br> 715 <br>--> 716 info = Struct(self._ofind(oname, namespaces))<br> 717 <br> 718 if info.found:<br><br>/home/gsever/Desktop/python-repo/ipython/IPython/ipstruct.pyc in __init__(self, dict, **kw)<br>
125 # safety-checked __setitem__<br><br> 126 for k,v in dict.items():<br>--> 127 self[k] = v<br> 128 <br> 129 <br><br>/home/gsever/Desktop/python-repo/ipython/IPython/ipstruct.pyc in __setitem__(self, key, value)<br>
135 raise KeyError(<br><br>*** ERROR: EOF in multi-line statement<br><br> 136 "Can't create unknown attribute %s - Check for typos, or use allow_new_attr to create new attributes!" %<br>
--> 137 key)<br><br>*** ERROR: EOF in multi-line statement<br><br> 138 <br> 139 self.__dict__[key] = value<br><br>KeyError: "Can't create unknown attribute obj - Check for typos, or use allow_new_attr to create new attributes!"<br>
<br>I[5]: exit()<br>Do you really want to exit ([y]/n)? y<br><br>I[6]: # Still in IPython<br><br><br><b>3) Using the default interpreter:</b><br><br>[gsever@ccn Desktop]$ python<br>Python 2.6 (r26:66714, Jun 8 2009, 16:07:26) <br>
[GCC 4.4.0 20090506 (Red Hat 4.4.0-4)] on linux2<br>Type "help", "copyright", "credits" or "license" for more information.<br>>>> __builtins__.True = False<br>>>> __builtins__.True == True<br>
True<br>>>> True == False<br>True<br><br>The book says this type of assignment is not allowed in Python 3. So far, this is the weirdest issue I have ever seen relating to the IPython.<br clear="all"><br>-- <br><font color="#888888">Gökhan<br>
</font><br></div></div>_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org" target="_blank">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
<br></blockquote></div><br>
</blockquote></div><br><br clear="all"><br>-- <br>Gökhan<br>