rkern / line_profiler

(OLD REPO) Line-by-line profiling for Python - Current repo ->
https://github.com/pyutils/line_profiler
Other
3.6k stars 254 forks source link

BUG: Switched to new way of registering ipython magics #68

Closed KristianHolsheimer closed 7 years ago

KristianHolsheimer commented 8 years ago

Hi Robert,

Thanks for the awesome package, it's been a lifesaver on many occasions!

This is a minor change, implementing the new way of registering ipython magics. Namely, get_ipython().define_magic(...) was apparently deprecated. The new way uses get_ipython().register_magic_function(...) instead. I did leave the old one in for backward compatibility.

Cheers, -Kris

MSeifert04 commented 8 years ago

This doesn't work for me IPython 5.1, Python 3.5: %lprun -f ....

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

C:\-\lib\site-packages\IPython\core\interactiveshell.py in magic(self, arg_s)
   2156         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2157         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2158         return self.run_line_magic(magic_name, magic_arg_s)
   2159 
   2160     #-------------------------------------------------------------------------

C:\-\lib\site-packages\IPython\core\interactiveshell.py in run_line_magic(self, magic_name, line)
   2077                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2078             with self.builtin_trap:
-> 2079                 result = fn(*args,**kwargs)
   2080             return result
   2081 

C:\-\lib\site-packages\line_profiler.py in magic_lprun(self, parameter_s)
    281     opts_def = Struct(D=[''], T=[''], f=[], m=[])
    282     parameter_s = parameter_s.replace('"', r'\"').replace("'", r"\'")
--> 283     opts, arg_str = self.parse_options(parameter_s, 'rsf:m:D:T:', list_all=True)
    284     opts.merge(opts_def)
    285 

AttributeError: 'str' object has no attribute 'parse_options'
patricksnape commented 8 years ago

This is not sufficient, the signature to magic functions has changed, #65 is the correct fix.

caethan commented 7 years ago

Fixed by the 2.0 release.