halostatue-archive / rubypython

An in-process between Ruby and Python 2.
Other
254 stars 47 forks source link

Rubypython interpreter doesn't start in presence of 'bson' gem. #29

Open tauqs opened 7 years ago

tauqs commented 7 years ago

Rubypython.start doesn't work when bson gem is present in the requirements.

This is the code that I wrote:

require 'rubypython' require 'bson'

RubyPython.start sys = RubyPython.import("sys") p sys.path RubyPython.stop

When I run this code, Rubypython.start generates following error:

/usr/local/rvm/rubies/ruby-2.2.5/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/tauq/Documents/Oz/Tauqueer/cluster1/cluster.rb /usr/local/rvm/gems/ruby-2.2.5/gems/rubypython-0.6.4/lib/rubypython/pymainclass.rb:50:in method_missing': undefined methodclass' for <module 'main' (built-in)>:RubyPython::PyMainClass (NoMethodError) from /usr/local/rvm/gems/ruby-2.2.5/gems/bson-4.2.2/lib/bson/specialized.rb:36:in ==' from /usr/local/rvm/gems/ruby-2.2.5/gems/rubypython-0.6.4/lib/rubypython.rb:219:in===' from /usr/local/rvm/gems/ruby-2.2.5/gems/rubypython-0.6.4/lib/rubypython.rb:219:in block in notify' from /usr/local/rvm/gems/ruby-2.2.5/gems/rubypython-0.6.4/lib/rubypython.rb:218:ineach' from /usr/local/rvm/gems/ruby-2.2.5/gems/rubypython-0.6.4/lib/rubypython.rb:218:in notify' from /usr/local/rvm/gems/ruby-2.2.5/gems/rubypython-0.6.4/lib/rubypython.rb:77:inblock in start' from /usr/local/rvm/gems/ruby-2.2.5/gems/rubypython-0.6.4/lib/rubypython/python.rb:11:in synchronize' from /usr/local/rvm/gems/ruby-2.2.5/gems/rubypython-0.6.4/lib/rubypython/python.rb:11:insynchronize' from /usr/local/rvm/gems/ruby-2.2.5/gems/rubypython-0.6.4/lib/rubypython.rb:54:in start' from /Users/tauq/Documents/Oz/Tauqueer/cluster1/cluster.rb:3:in<top (required)>' from -e:1:in load' from -e:1:in

'

Process finished with exit code 1

========================================================================

This won't happen if I don't use bson gem. Please look into the issue.

peter-wangxu commented 7 years ago

@tauqueer28 The issue is caused by the require bson statement.

The === and == are overwritten by the bson\specialized.rb

when comparing the nil with an rubypython internal object error occurred due to the absense of class property of RubyPython object.

My suggestion is to file a issue/question firstly in bson (I do have concern of bson's above behavior) and ask for narrowing down the side effect of overwriting the global operators.

Thanks Peter