Show More
@@ -114,6 +114,11 b' except NameError:' | |||||
114 | items.reverse() |
|
114 | items.reverse() | |
115 | return items |
|
115 | return items | |
116 |
|
116 | |||
|
117 | try: # Python 2.4 compatibility | |||
|
118 | GeneratorExit | |||
|
119 | except NameError: | |||
|
120 | GeneratorExit = SystemExit | |||
|
121 | ||||
117 | try: |
|
122 | try: | |
118 | import pwd |
|
123 | import pwd | |
119 | except ImportError: |
|
124 | except ImportError: | |
@@ -666,7 +671,7 b' def xrepr(item, mode="default"):' | |||||
666 | try: |
|
671 | try: | |
667 | for x in func(mode): |
|
672 | for x in func(mode): | |
668 | yield x |
|
673 | yield x | |
669 | except (KeyboardInterrupt, SystemExit): |
|
674 | except (KeyboardInterrupt, SystemExit, GeneratorExit): | |
670 | raise |
|
675 | raise | |
671 | except Exception: |
|
676 | except Exception: | |
672 | yield (astyle.style_default, repr(item)) |
|
677 | yield (astyle.style_default, repr(item)) | |
@@ -840,20 +845,20 b' def upgradexattr(attr):' | |||||
840 | """ |
|
845 | """ | |
841 | Convert an attribute descriptor string to a real descriptor object. |
|
846 | Convert an attribute descriptor string to a real descriptor object. | |
842 |
|
847 | |||
843 |
If attr already is a descriptor object return i |
|
848 | If attr already is a descriptor object return it unmodified. A | |
844 | ``SelfDescriptor`` will be returned if ``attr`` is ``None``. ``"foo"`` |
|
849 | ``SelfDescriptor`` will be returned if ``attr`` is ``None``. ``"foo"`` | |
845 | returns an ``AttributeDescriptor`` for the attribute named ``"foo"``. |
|
850 | returns an ``AttributeDescriptor`` for the attribute named ``"foo"``. | |
846 | ``"foo()"`` returns a ``MethodDescriptor`` for the method named ``"foo"``. |
|
851 | ``"foo()"`` returns a ``MethodDescriptor`` for the method named ``"foo"``. | |
847 | ``"-foo"`` will return an ``IterAttributeDescriptor`` for the attribute |
|
852 | ``"-foo"`` will return an ``IterAttributeDescriptor`` for the attribute | |
848 | named ``"foo"`` and ``"-foo()"`` will return an ``IterMethodDescriptor`` |
|
853 | named ``"foo"`` and ``"-foo()"`` will return an ``IterMethodDescriptor`` | |
849 | for the method named ``"foo"``. Furthermore integer will return the appropriate |
|
854 | for the method named ``"foo"``. Furthermore integers will return the appropriate | |
850 | ``IndexDescriptor`` and callables will return a ``FunctionDescriptor``. |
|
855 | ``IndexDescriptor`` and callables will return a ``FunctionDescriptor``. | |
851 | """ |
|
856 | """ | |
852 | if attr is None: |
|
857 | if attr is None: | |
853 | return selfdescriptor |
|
858 | return selfdescriptor | |
854 | elif isinstance(attr, Descriptor): |
|
859 | elif isinstance(attr, Descriptor): | |
855 | return attr |
|
860 | return attr | |
856 | elif isinstance(attr, str): |
|
861 | elif isinstance(attr, basestring): | |
857 | if attr.endswith("()"): |
|
862 | if attr.endswith("()"): | |
858 | if attr.startswith("-"): |
|
863 | if attr.startswith("-"): | |
859 | return IterMethodDescriptor(attr[1:-2]) |
|
864 | return IterMethodDescriptor(attr[1:-2]) |
@@ -1675,7 +1675,7 b' Currently the magic system has the following functions:\\n"""' | |||||
1675 | exit_ignore=exit_ignore) |
|
1675 | exit_ignore=exit_ignore) | |
1676 | t1 = clock2() |
|
1676 | t1 = clock2() | |
1677 | t_usr = t1[0]-t0[0] |
|
1677 | t_usr = t1[0]-t0[0] | |
1678 |
t_sys = t1[1]-t |
|
1678 | t_sys = t1[1]-t0[1] | |
1679 | print "\nIPython CPU timings (estimated):" |
|
1679 | print "\nIPython CPU timings (estimated):" | |
1680 | print " User : %10s s." % t_usr |
|
1680 | print " User : %10s s." % t_usr | |
1681 | print " System: %10s s." % t_sys |
|
1681 | print " System: %10s s." % t_sys | |
@@ -1687,7 +1687,7 b' Currently the magic system has the following functions:\\n"""' | |||||
1687 | exit_ignore=exit_ignore) |
|
1687 | exit_ignore=exit_ignore) | |
1688 | t1 = clock2() |
|
1688 | t1 = clock2() | |
1689 | t_usr = t1[0]-t0[0] |
|
1689 | t_usr = t1[0]-t0[0] | |
1690 |
t_sys = t1[1]-t |
|
1690 | t_sys = t1[1]-t0[1] | |
1691 | print "\nIPython CPU timings (estimated):" |
|
1691 | print "\nIPython CPU timings (estimated):" | |
1692 | print "Total runs performed:",nruns |
|
1692 | print "Total runs performed:",nruns | |
1693 | print " Times : %10s %10s" % ('Total','Per run') |
|
1693 | print " Times : %10s %10s" % ('Total','Per run') |
@@ -292,17 +292,19 b' if HAS_CTYPES:' | |||||
292 | """raises the exception, performs cleanup if needed""" |
|
292 | """raises the exception, performs cleanup if needed""" | |
293 | if not inspect.isclass(exctype): |
|
293 | if not inspect.isclass(exctype): | |
294 | raise TypeError("Only types can be raised (not instances)") |
|
294 | raise TypeError("Only types can be raised (not instances)") | |
295 | res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, |
|
295 | # Explicit cast to c_long is necessary for 64-bit support: | |
|
296 | # See https://bugs.launchpad.net/ipython/+bug/237073 | |||
|
297 | res = ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(tid), | |||
296 | ctypes.py_object(exctype)) |
|
298 | ctypes.py_object(exctype)) | |
297 | if res == 0: |
|
299 | if res == 0: | |
298 | raise ValueError("invalid thread id") |
|
300 | raise ValueError("invalid thread id") | |
299 | elif res != 1: |
|
301 | elif res != 1: | |
300 |
# |
|
302 | # If it returns a number greater than one, you're in trouble, | |
301 |
# and you should call it again with exc=NULL to revert the effect |
|
303 | # and you should call it again with exc=NULL to revert the effect | |
302 | ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, 0) |
|
304 | ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, 0) | |
303 | raise SystemError("PyThreadState_SetAsyncExc failed") |
|
305 | raise SystemError("PyThreadState_SetAsyncExc failed") | |
304 |
|
306 | |||
305 |
def sigint_handler |
|
307 | def sigint_handler(signum,stack_frame): | |
306 | """Sigint handler for threaded apps. |
|
308 | """Sigint handler for threaded apps. | |
307 |
|
309 | |||
308 | This is a horrible hack to pass information about SIGINT _without_ |
|
310 | This is a horrible hack to pass information about SIGINT _without_ | |
@@ -321,7 +323,7 b' if HAS_CTYPES:' | |||||
321 | Term.cout.flush() |
|
323 | Term.cout.flush() | |
322 |
|
324 | |||
323 | else: |
|
325 | else: | |
324 |
def sigint_handler |
|
326 | def sigint_handler(signum,stack_frame): | |
325 | """Sigint handler for threaded apps. |
|
327 | """Sigint handler for threaded apps. | |
326 |
|
328 | |||
327 | This is a horrible hack to pass information about SIGINT _without_ |
|
329 | This is a horrible hack to pass information about SIGINT _without_ |
@@ -248,7 +248,7 b' class BackgroundJobManager:' | |||||
248 | self._update_status() |
|
248 | self._update_status() | |
249 | new_comp = self._group_report(self._comp_report,'Completed') |
|
249 | new_comp = self._group_report(self._comp_report,'Completed') | |
250 | new_dead = self._group_report(self._dead_report, |
|
250 | new_dead = self._group_report(self._dead_report, | |
251 | 'Dead, call job.traceback() for details') |
|
251 | 'Dead, call jobs.traceback() for details') | |
252 | self._comp_report[:] = [] |
|
252 | self._comp_report[:] = [] | |
253 | self._dead_report[:] = [] |
|
253 | self._dead_report[:] = [] | |
254 | return new_comp or new_dead |
|
254 | return new_comp or new_dead | |
@@ -340,7 +340,7 b' class BackgroundJobBase(threading.Thread):' | |||||
340 | stat_created = 'Created'; stat_created_c = 0 |
|
340 | stat_created = 'Created'; stat_created_c = 0 | |
341 | stat_running = 'Running'; stat_running_c = 1 |
|
341 | stat_running = 'Running'; stat_running_c = 1 | |
342 | stat_completed = 'Completed'; stat_completed_c = 2 |
|
342 | stat_completed = 'Completed'; stat_completed_c = 2 | |
343 | stat_dead = 'Dead (Exception), call job.traceback() for details' |
|
343 | stat_dead = 'Dead (Exception), call jobs.traceback() for details' | |
344 | stat_dead_c = -1 |
|
344 | stat_dead_c = -1 | |
345 |
|
345 | |||
346 | def __init__(self): |
|
346 | def __init__(self): | |
@@ -391,7 +391,7 b' class BackgroundJobBase(threading.Thread):' | |||||
391 | self.status = BackgroundJobBase.stat_dead |
|
391 | self.status = BackgroundJobBase.stat_dead | |
392 | self.stat_code = BackgroundJobBase.stat_dead_c |
|
392 | self.stat_code = BackgroundJobBase.stat_dead_c | |
393 | self.finished = None |
|
393 | self.finished = None | |
394 | self.result = ('<BackgroundJob died, call job.traceback() for details>') |
|
394 | self.result = ('<BackgroundJob died, call jobs.traceback() for details>') | |
395 | self._tb = self._make_tb() |
|
395 | self._tb = self._make_tb() | |
396 | else: |
|
396 | else: | |
397 | self.status = BackgroundJobBase.stat_completed |
|
397 | self.status = BackgroundJobBase.stat_completed |
General Comments 0
You need to be logged in to leave comments.
Login now