Skip to content
This repository has been archived by the owner on Jan 11, 2022. It is now read-only.

Commit

Permalink
Fix BigNum to python long long issue (#5)
Browse files Browse the repository at this point in the history
* Fix BigNum to python long long issue

This bug fix the issue when passing ruby BigNum as a
parameter of python function

* Add lib path for debian/ubuntu

* Update version to 0.6.4
  • Loading branch information
peter-wangxu authored Jun 22, 2017
1 parent c491c32 commit 48d97d4
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
6 changes: 5 additions & 1 deletion History.rdoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
=== 0.6.3 / 2012-09-25
=== 0.6.4 / 2017-06-20
* Fix long conversion issue
* Fix lib path for Debian/Ubuntu

=== 0.6.4 / 2012-09-25
* Major Enhancements
* Legacy Mode removed
* Minor Enhancements
Expand Down
2 changes: 1 addition & 1 deletion lib/rubypython.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# puts cPickle.dumps("RubyPython is awesome!").rubify
# RubyPython.stop
module RubyPython
VERSION = '0.6.3'
VERSION = '0.6.4'
end

require 'rubypython/blankobject'
Expand Down
2 changes: 1 addition & 1 deletion lib/rubypython/conversion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def self.rtopFixnum(rNum)
# Convert a Ruby Bignum to a \Python Long. Returns an FFI::Pointer to a
# PyLongObject.
def self.rtopBigNum(rNum)
num = RubyPython::Python.PyLong_FromLong(rNum)
num = RubyPython::Python.PyLong_FromLongLong(rNum)
raise ConversionError.new "Failed to convert #{rNum}" if num.null?
num
end
Expand Down
1 change: 1 addition & 0 deletions lib/rubypython/interpreter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def find_python_lib
@locations << File.join("/opt/lib64", name)
@locations << File.join("/usr/local/lib64", name)
@locations << File.join("/usr/lib64", name)
@locations << File.join("/usr/lib/x86_64-linux-gnu", name)
end
@locations << File.join("/opt/local/lib", name)
@locations << File.join("/opt/lib", name)
Expand Down
12 changes: 7 additions & 5 deletions lib/rubypython/python.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module RubyPython
# This module will hold the loaded RubyPython interpreter.
module Python #:nodoc: all
@lock = Mutex.new

def self.synchronize(&block)
@lock.synchronize(&block)
end
Expand Down Expand Up @@ -84,7 +85,7 @@ def infect!(mod)
attach_function :PyInt_FromLong, [:long], :pointer

attach_function :PyLong_AsLong, [:pointer], :long
attach_function :PyLong_FromLong, [:pointer], :long
attach_function :PyLong_FromLongLong, [:long_long], :pointer

# Float Methods
attach_function :PyFloat_AsDouble, [:pointer], :double
Expand Down Expand Up @@ -182,16 +183,17 @@ def infect!(mod)
# pointers there is no need to mess around with the rest of the object.
self.const_set :PyObjectStruct, Class.new(::FFI::Struct)
self::PyObjectStruct.layout :ob_refcnt, :ssize_t,
:ob_type, :pointer
:ob_type, :pointer

# This struct is used when defining Python methods.
self.const_set :PyMethodDef, Class.new(::FFI::Struct)
self::PyMethodDef.layout :ml_name, :pointer,
:ml_meth, :PyCFunction,
:ml_flags, :int,
:ml_doc, :pointer
:ml_meth, :PyCFunction,
:ml_flags, :int,
:ml_doc, :pointer
end

end

private :infect!
end
6 changes: 3 additions & 3 deletions rubypython.gemspec
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- encoding: utf-8 -*-
# stub: rubypython 0.6.3 ruby lib
# stub: rubypython 0.6.4 ruby lib

Gem::Specification.new do |s|
s.name = "rubypython"
s.version = "0.6.3"
s.version = "0.6.4"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
Expand All @@ -12,7 +12,7 @@ Gem::Specification.new do |s|
s.description = "RubyPython is a bridge between the Ruby and Python interpreters. It embeds a\nrunning Python interpreter in the Ruby application's process using FFI and\nprovides a means for wrapping, converting, and calling Python objects and\nmethods.\n\nRubyPython uses FFI to marshal the data between the Ruby and Python VMs and\nmake Python calls. You can:\n\n* Inherit from Python classes.\n* Configure callbacks from Python.\n* Run Python generators (on Ruby 1.9.2 or later)."
s.email = ["swiuzzz+rubypython@gmail.com", "austin@rubyforge.org", "raineszm+rubypython@gmail.com"]
s.extra_rdoc_files = ["Contributors.rdoc", "History.rdoc", "License.rdoc", "Manifest.txt", "PostInstall.txt", "README.rdoc", "website/robots.txt", "Contributors.rdoc", "History.rdoc", "License.rdoc", "README.rdoc"]
s.files = [".autotest", ".gemtest", ".gitignore", ".hgignore", ".hgtags", ".rspec", "Contributors.rdoc", "History.rdoc", "License.rdoc", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "autotest/discover.rb", "lib/rubypython.rb", "lib/rubypython/blankobject.rb", "lib/rubypython/conversion.rb", "lib/rubypython/interpreter.rb", "lib/rubypython/macros.rb", "lib/rubypython/operators.rb", "lib/rubypython/pygenerator.rb", "lib/rubypython/pymainclass.rb", "lib/rubypython/pyobject.rb", "lib/rubypython/python.rb", "lib/rubypython/pythonerror.rb", "lib/rubypython/rubypyproxy.rb", "lib/rubypython/tuple.rb", "lib/rubypython/type.rb", "spec/basic_spec.rb", "spec/callback_spec.rb", "spec/conversion_spec.rb", "spec/pymainclass_spec.rb", "spec/pyobject_spec.rb", "spec/python_helpers/basics.py", "spec/python_helpers/errors.py", "spec/python_helpers/objects.py", "spec/pythonerror_spec.rb", "spec/refcnt_spec.rb", "spec/rubypyclass_spec.rb", "spec/rubypyproxy_spec.rb", "spec/rubypython_spec.rb", "spec/spec_helper.rb", "website/index.rhtml", "website/robots.txt", "website/stylesheets/960.css", "website/stylesheets/border-radius.htc", "website/stylesheets/screen.css"]
s.files = [".autotest", ".gitignore", ".hgignore", ".hgtags", ".rspec", "Contributors.rdoc", "History.rdoc", "License.rdoc", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "autotest/discover.rb", "lib/rubypython.rb", "lib/rubypython/blankobject.rb", "lib/rubypython/conversion.rb", "lib/rubypython/interpreter.rb", "lib/rubypython/macros.rb", "lib/rubypython/operators.rb", "lib/rubypython/pygenerator.rb", "lib/rubypython/pymainclass.rb", "lib/rubypython/pyobject.rb", "lib/rubypython/python.rb", "lib/rubypython/pythonerror.rb", "lib/rubypython/rubypyproxy.rb", "lib/rubypython/tuple.rb", "lib/rubypython/type.rb", "spec/basic_spec.rb", "spec/callback_spec.rb", "spec/conversion_spec.rb", "spec/pymainclass_spec.rb", "spec/pyobject_spec.rb", "spec/python_helpers/basics.py", "spec/python_helpers/errors.py", "spec/python_helpers/objects.py", "spec/pythonerror_spec.rb", "spec/refcnt_spec.rb", "spec/rubypyclass_spec.rb", "spec/rubypyproxy_spec.rb", "spec/rubypython_spec.rb", "spec/spec_helper.rb", "website/index.rhtml", "website/robots.txt", "website/stylesheets/960.css", "website/stylesheets/border-radius.htc", "website/stylesheets/screen.css"]
s.licenses = ["MIT"]
s.rdoc_options = ["--main", "README.rdoc"]
s.requirements = ["Python, ~> 2.4"]
Expand Down

0 comments on commit 48d97d4

Please sign in to comment.