Closed Frefreak closed 7 years ago
R2pipe != rlang != r2api
On 15 May 2017, at 11:19, Frefreak notifications@github.com wrote:
Hi, when I tried #!python with the latest git version, it shows: NameError: name 'RCore' is not defined. I already installed r2lang with r2pm -i lang-python and lastest r2pipe. Tried both py2 and py3 build and the behavior is the same.
how to reproduce:
λ ~ r2 - -- Welcome to "IDA - the roguelike" [0x00000000]> #!python Traceback (most recent call last): File "
", line 1, in NameError: name 'RCore' is not defined Python 2.7.13 (default, Feb 11 2017, 12:22:40) Type "copyright", "credits" or "license" for more information. IPython 5.3.0 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details.
In [1]:
Do you really want to exit ([y]/n)?[0x00000000]> #!python -e "print(3)"
NameError Traceback (most recent call last)
in () NameError: name 'RCore' is not defined [0x00000000]> from my understanding this happens in the setup function in python.c, it tries to run core=RCore.ncast(0x........) to get a variable of RCore type. RCore is tryed to be imported but would fail since r2pipe has no r_core. (https://github.com/radare/radare2-bindings/blob/master/libr/lang/p/python.c#L283) Now r2pipe will auto detect the existence of r2lang and set it's cmd method correctly, this "defines" parts seems not necessary anymore? Or we might somehow need to expose RCore type in python space to make the def works? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
If import r_core doesnt works for you then you have to install the r2api pkg
On 15 May 2017, at 11:19, Frefreak notifications@github.com wrote:
Hi, when I tried #!python with the latest git version, it shows: NameError: name 'RCore' is not defined. I already installed r2lang with r2pm -i lang-python and lastest r2pipe. Tried both py2 and py3 build and the behavior is the same.
how to reproduce:
λ ~ r2 - -- Welcome to "IDA - the roguelike" [0x00000000]> #!python Traceback (most recent call last): File "
", line 1, in NameError: name 'RCore' is not defined Python 2.7.13 (default, Feb 11 2017, 12:22:40) Type "copyright", "credits" or "license" for more information. IPython 5.3.0 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details.
In [1]:
Do you really want to exit ([y]/n)?[0x00000000]> #!python -e "print(3)"
NameError Traceback (most recent call last)
in () NameError: name 'RCore' is not defined [0x00000000]> from my understanding this happens in the setup function in python.c, it tries to run core=RCore.ncast(0x........) to get a variable of RCore type. RCore is tryed to be imported but would fail since r2pipe has no r_core. (https://github.com/radare/radare2-bindings/blob/master/libr/lang/p/python.c#L283) Now r2pipe will auto detect the existence of r2lang and set it's cmd method correctly, this "defines" parts seems not necessary anymore? Or we might somehow need to expose RCore type in python space to make the def works? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Sorry, I misunderstood that line. After installing r2api-python its working now.
But shouldn't the code detect whether r2api exists and not try to run core=RCore.ncast(...)
if not? The user can interact with RCore through r2pipe in that case. The NameError should not arise.
yes, it does this chack already, i cant reproduce any of those issues having or not having r2api-python installed. ... so :?
That's weird... Could you please point out where is the check?
https://github.com/radare/radare2-bindings/blob/master/libr/lang/p/python.c#L281 https://github.com/radare/radare2-bindings/blob/master/libr/lang/p/python.c#L281
On 15 May 2017, at 14:45, Frefreak notifications@github.com wrote:
That's weird... Could you please point out where is the check?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/radare/radare2-bindings/issues/159#issuecomment-301463791, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3-lq6nXQlGUPqnytsn6OMJe9EAR0sHks5r6EjWgaJpZM4Na3v8.
That's not preventing the error. The error happens in https://github.com/radare/radare2-bindings/blob/master/libr/lang/p/python.c#L298, which is executed regardless of whether the import success or not.
Send a pr
On 15 May 2017, at 14:56, Frefreak notifications@github.com wrote:
That's not preventing the error. The error happens in https://github.com/radare/radare2-bindings/blob/master/libr/lang/p/python.c#L298, which is executed regardless of whether the import success or not.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
Hi, when I tried
#!python
with the latest git version, it shows:NameError: name 'RCore' is not defined
. I already installed r2lang withr2pm -i lang-python
and lastest r2pipe. Tried both py2 and py3 build and the behavior is the same.how to reproduce:
from my understanding this happens in the setup function in python.c, it tries to run
core=RCore.ncast(0x........)
to get a variable ofRCore
type.RCore
istry
ed to be imported but would fail since r2pipe has nor_core
. (https://github.com/radare/radare2-bindings/blob/master/libr/lang/p/python.c#L283)Now r2pipe will auto detect the existence of r2lang and set it's cmd method correctly, this "defines" parts seems not necessary anymore? Or we might somehow need to expose
RCore
type in python space to make the def works?