Show More
@@ -827,29 +827,32 b' class AutoHandler(PrefilterHandler):' | |||||
827 | newcmd = '%s(%s)' % (ifun,",".join(the_rest.split())) |
|
827 | newcmd = '%s(%s)' % (ifun,",".join(the_rest.split())) | |
828 | else: |
|
828 | else: | |
829 | # Auto-paren. |
|
829 | # Auto-paren. | |
830 | # We only apply it to argument-less calls if the autocall |
|
830 | if force_auto: | |
831 | # parameter is set to 2. We only need to check that autocall is < |
|
831 | # Don't rewrite if it is already a call. | |
832 | # 2, since this function isn't called unless it's at least 1. |
|
832 | do_rewrite = not the_rest.startswith('(') | |
833 | if (not the_rest and (self.shell.autocall < 2) and not force_auto) \ |
|
|||
834 | or the_rest.startswith("("): |
|
|||
835 | newcmd = '%s %s' % (ifun,the_rest) |
|
|||
836 | auto_rewrite = False |
|
|||
837 | else: |
|
833 | else: | |
838 |
if not |
|
834 | if not the_rest: | |
839 | if hasattr(obj,'__getitem__'): |
|
835 | # We only apply it to argument-less calls if the autocall | |
|
836 | # parameter is set to 2. | |||
|
837 | do_rewrite = (self.shell.autocall >= 2) | |||
|
838 | elif the_rest.startswith('[') and hasattr(obj, '__getitem__'): | |||
840 |
|
|
839 | # Don't autocall in this case: item access for an object | |
841 |
|
|
840 | # which is BOTH callable and implements __getitem__. | |
842 | newcmd = '%s %s' % (ifun,the_rest) |
|
841 | do_rewrite = False | |
843 | auto_rewrite = False |
|
|||
844 |
|
|
842 | else: | |
845 | # if the object doesn't support [] access, go ahead and |
|
843 | do_rewrite = True | |
846 | # autocall |
|
844 | ||
847 | newcmd = '%s(%s)' % (ifun.rstrip(),the_rest) |
|
845 | # Figure out the rewritten command | |
848 |
|
|
846 | if do_rewrite: | |
|
847 | if the_rest.endswith(';'): | |||
849 | newcmd = '%s(%s);' % (ifun.rstrip(),the_rest[:-1]) |
|
848 | newcmd = '%s(%s);' % (ifun.rstrip(),the_rest[:-1]) | |
850 | else: |
|
849 | else: | |
851 | newcmd = '%s(%s)' % (ifun.rstrip(), the_rest) |
|
850 | newcmd = '%s(%s)' % (ifun.rstrip(), the_rest) | |
|
851 | else: | |||
|
852 | normal_handler = self.prefilter_manager.get_handler_by_name('normal') | |||
|
853 | return normal_handler.handle(line_info) | |||
852 |
|
854 | |||
|
855 | # Display the rewritten call | |||
853 | if auto_rewrite: |
|
856 | if auto_rewrite: | |
854 | self.shell.auto_rewrite_input(newcmd) |
|
857 | self.shell.auto_rewrite_input(newcmd) | |
855 |
|
858 |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
General Comments 0
You need to be logged in to leave comments.
Login now