Skip to content

Commit 57aa616

Browse files
committed
Also protect remaining part of get_args from user code exceptions (fixes #776)
1 parent 14c17c1 commit 57aa616

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

bpython/repl.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -626,31 +626,31 @@ def get_args(self):
626626
fake_cursor, self.current_line, self.interp.locals)
627627
except simpleeval.EvaluationError:
628628
return False
629+
630+
if inspect.isclass(f):
631+
class_f = None
632+
633+
if (hasattr(f, '__init__') and
634+
f.__init__ is not object.__init__):
635+
class_f = f.__init__
636+
if ((not class_f or
637+
not inspection.getfuncprops(func, class_f)) and
638+
hasattr(f, '__new__') and
639+
f.__new__ is not object.__new__ and
640+
# py3
641+
f.__new__.__class__ is not object.__new__.__class__):
642+
643+
class_f = f.__new__
644+
645+
if class_f:
646+
f = class_f
629647
except Exception:
630648
# another case of needing to catch every kind of error
631649
# since user code is run in the case of descriptors
632650
# XXX: Make sure you raise here if you're debugging the completion
633651
# stuff !
634652
return False
635653

636-
if inspect.isclass(f):
637-
class_f = None
638-
639-
if (hasattr(f, '__init__') and
640-
f.__init__ is not object.__init__):
641-
class_f = f.__init__
642-
if ((not class_f or
643-
not inspection.getfuncprops(func, class_f)) and
644-
hasattr(f, '__new__') and
645-
f.__new__ is not object.__new__ and
646-
# py3
647-
f.__new__.__class__ is not object.__new__.__class__):
648-
649-
class_f = f.__new__
650-
651-
if class_f:
652-
f = class_f
653-
654654
self.current_func = f
655655
self.funcprops = inspection.getfuncprops(func, f)
656656
if self.funcprops:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy