rubypython 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Contributors.rdoc +1 -0
- data/History.rdoc +7 -0
- data/Manifest.txt +1 -0
- data/README.rdoc +5 -5
- data/Rakefile +0 -1
- data/lib/rubypython.rb +2 -2
- data/lib/rubypython/pythonerror.rb +14 -3
- data/lib/rubypython/pythonexec.rb +22 -4
- data/spec/python_helpers/errors.py +2 -0
- data/spec/pythonerror_spec.rb +14 -0
- metadata +16 -34
data/Contributors.rdoc
CHANGED
data/History.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
=== 0.5.2 / 2011-10-21
|
2
|
+
* Minor Enhancements:
|
3
|
+
* The traceback for Python exceptions is now returned usefully. [raineszm]
|
4
|
+
* Bug Fixes:
|
5
|
+
* Improved the robustness of Windows DLL detection. Based on work by
|
6
|
+
bendoerr, raineszm, and halostatue.
|
7
|
+
|
1
8
|
=== 0.5.1 / 2011-03-17
|
2
9
|
* Major Enhancements:
|
3
10
|
* Procs and methods can be passed to Python. [raineszm]
|
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
@@ -71,7 +71,7 @@ start before running the code provided in the block and stop it afterwards.
|
|
71
71
|
RubyPython.start_from_virtualenv("/path/to/virtualenv")
|
72
72
|
|
73
73
|
# Or verbose
|
74
|
-
RubyPython.start(:
|
74
|
+
RubyPython.start(:python_exe => "/path/to/virtualenv/bin/python")
|
75
75
|
RubyPython.activate
|
76
76
|
|
77
77
|
=== Iterator support
|
@@ -259,10 +259,10 @@ It should work with other implementations that support the Ruby FFI gem with no
|
|
259
259
|
modification.
|
260
260
|
|
261
261
|
=== OS Support
|
262
|
-
RubyPython has been tested on Mac OS 10.5 and 10.6, and Ubuntu
|
263
|
-
Intel). If your platform has a DLL or shared object version of
|
264
|
-
supports the FFI gem, it should work. Feedback on other platforms is
|
265
|
-
welcome.
|
262
|
+
RubyPython has been extensively tested on Mac OS 10.5 and 10.6, and Ubuntu
|
263
|
+
10.10 (64-bit Intel). If your platform has a DLL or shared object version of
|
264
|
+
Python and supports the FFI gem, it should work. Feedback on other platforms is
|
265
|
+
always welcome.
|
266
266
|
|
267
267
|
== Install
|
268
268
|
gem install rubypython
|
data/Rakefile
CHANGED
data/lib/rubypython.rb
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
# puts cPickle.dumps("RubyPython is awesome!").rubify
|
16
16
|
# RubyPython.stop
|
17
17
|
module RubyPython
|
18
|
-
VERSION = '0.5.
|
18
|
+
VERSION = '0.5.2' #:nodoc:
|
19
19
|
|
20
20
|
# Do not load the FFI interface by default. Wait until the user asks for
|
21
21
|
# it.
|
@@ -217,7 +217,7 @@ module RubyPython
|
|
217
217
|
# is *strongly* discouraged as this may lead to segmentation faults.
|
218
218
|
# This feature is highly experimental and may be disabled in the future.
|
219
219
|
def start_from_virtualenv(virtualenv)
|
220
|
-
result = start(:
|
220
|
+
result = start(:python_exe => File.join(virtualenv, "bin", "python"))
|
221
221
|
activate
|
222
222
|
result
|
223
223
|
end
|
@@ -3,11 +3,17 @@ require 'rubypython/macros'
|
|
3
3
|
|
4
4
|
# Raised when an error occurs in the \Python interpreter.
|
5
5
|
class RubyPython::PythonError < RuntimeError
|
6
|
+
# The \Python traceback object associated with this error. This will be
|
7
|
+
# a RubyPython::RubyPyProxy object.
|
8
|
+
attr_reader :traceback
|
9
|
+
|
6
10
|
# Creates the PythonError.
|
7
11
|
# [typeName] The class name of the \Python error.
|
8
12
|
# [msg] The message attached to the \Python error.
|
9
|
-
|
13
|
+
# [traceback] The traceback, if any, associated with the \Python error.
|
14
|
+
def initialize(typeName, msg, traceback = nil)
|
10
15
|
@type = typeName
|
16
|
+
@traceback = traceback
|
11
17
|
super([typeName, msg].join(': '))
|
12
18
|
end
|
13
19
|
|
@@ -27,10 +33,15 @@ class RubyPython::PythonError < RuntimeError
|
|
27
33
|
msg = nil
|
28
34
|
end
|
29
35
|
|
36
|
+
if not rbTraceback.null?
|
37
|
+
traceback = RubyPython::RubyPyProxy.new rbTraceback
|
38
|
+
else
|
39
|
+
traceback = nil
|
40
|
+
end
|
41
|
+
|
30
42
|
# Decrease the reference count. This will happen anyway when they go out
|
31
43
|
# of scope but might as well.
|
32
44
|
rbValue.xDecref
|
33
|
-
rbTraceback.xDecref
|
34
45
|
pyName = rbType.getAttr("__name__")
|
35
46
|
|
36
47
|
rbType.xDecref
|
@@ -38,7 +49,7 @@ class RubyPython::PythonError < RuntimeError
|
|
38
49
|
pyName.xDecref
|
39
50
|
|
40
51
|
RubyPython::PythonError.clear
|
41
|
-
RubyPython::PythonError.new(rbName, msg)
|
52
|
+
RubyPython::PythonError.new(rbName, msg, traceback)
|
42
53
|
end
|
43
54
|
|
44
55
|
# A wrapper to the \Python C API +PyErr_Fetch+ function. Returns an array
|
@@ -15,11 +15,15 @@ class RubyPython::PythonExec
|
|
15
15
|
@python = python_executable || "python"
|
16
16
|
@python = %x(#{@python} -c "import sys; print sys.executable").chomp
|
17
17
|
|
18
|
-
@version = run_command
|
18
|
+
@version = run_command "import sys; print '%d.%d' % sys.version_info[:2]"
|
19
19
|
|
20
|
+
@dirname = File.dirname(@python)
|
20
21
|
@realname = @python.dup
|
21
|
-
if @realname !~ /#{@version}$/
|
22
|
+
if (@realname !~ /#{@version}$/ and @realname !~ /\.exe$/)
|
22
23
|
@realname = "#{@python}#{@version}"
|
24
|
+
else
|
25
|
+
basename = File.basename(@python, '.exe')
|
26
|
+
@realname = File.join(@dirname, "#{basename}#{@version.gsub(/\./, '')}")
|
23
27
|
end
|
24
28
|
@basename = File.basename(@realname)
|
25
29
|
|
@@ -62,6 +66,20 @@ class RubyPython::PythonExec
|
|
62
66
|
end
|
63
67
|
end
|
64
68
|
|
69
|
+
if FFI::Platform.windows?
|
70
|
+
# On Windows, the appropriate DLL is usually be found in
|
71
|
+
# %SYSTEMROOT%\system or %SYSTEMROOT%\system32; as a fallback we'll
|
72
|
+
# use C:\Windows\system{,32} as well as the install directory and the
|
73
|
+
# install directory + libs.
|
74
|
+
system_root = File.expand_path(ENV['SYSTEMROOT']).gsub(/\\/, '/')
|
75
|
+
locations << File.join(system_root, 'system', libname)
|
76
|
+
locations << File.join(system_root, 'system32', libname)
|
77
|
+
locations << File.join("C:/WINDOWS", "System", libname)
|
78
|
+
locations << File.join("C:/WINDOWS", "System32", libname)
|
79
|
+
locations << File.join(@dirname, libname)
|
80
|
+
locations << File.join(@dirname, 'libs', libname)
|
81
|
+
end
|
82
|
+
|
65
83
|
# Let's add alternative extensions; again, just in case.
|
66
84
|
locations.dup.each do |location|
|
67
85
|
path = File.dirname(location)
|
@@ -96,12 +114,12 @@ class RubyPython::PythonExec
|
|
96
114
|
attr_reader :sys_prefix
|
97
115
|
# The Python library.
|
98
116
|
attr_reader :library
|
99
|
-
#
|
117
|
+
# The Python version
|
100
118
|
attr_reader :version
|
101
119
|
|
102
120
|
# Run a Python command-line command.
|
103
121
|
def run_command(command)
|
104
|
-
%x(#{@python} -c
|
122
|
+
%x(#{@python} -c "#{command}").chomp if @python
|
105
123
|
end
|
106
124
|
|
107
125
|
def to_s
|
data/spec/pythonerror_spec.rb
CHANGED
@@ -35,4 +35,18 @@ describe RubyPython::PythonError do
|
|
35
35
|
rbType.getAttr("__name__").rubify.should == "ImportError"
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
describe ".last_traceback" do
|
40
|
+
it "should make availble the Python traceback of the last error" do
|
41
|
+
traceback = RubyPython.import 'traceback'
|
42
|
+
errors = RubyPython.import 'errors'
|
43
|
+
begin
|
44
|
+
errors.nested_error
|
45
|
+
rescue RubyPython::PythonError => exc
|
46
|
+
tb = exc.traceback
|
47
|
+
list = traceback.format_tb(tb)
|
48
|
+
list.rubify[0].should =~ /1 \/ 0/
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
38
52
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubypython
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 2
|
10
|
+
version: 0.5.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Steeve Morin
|
@@ -17,8 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-
|
21
|
-
default_executable:
|
20
|
+
date: 2011-10-21 00:00:00 Z
|
22
21
|
dependencies:
|
23
22
|
- !ruby/object:Gem::Dependency
|
24
23
|
name: ffi
|
@@ -53,26 +52,10 @@ dependencies:
|
|
53
52
|
version: 2.1.2.3
|
54
53
|
type: :runtime
|
55
54
|
version_requirements: *id002
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: rubyforge
|
58
|
-
prerelease: false
|
59
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
60
|
-
none: false
|
61
|
-
requirements:
|
62
|
-
- - ">="
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
hash: 7
|
65
|
-
segments:
|
66
|
-
- 2
|
67
|
-
- 0
|
68
|
-
- 4
|
69
|
-
version: 2.0.4
|
70
|
-
type: :development
|
71
|
-
version_requirements: *id003
|
72
55
|
- !ruby/object:Gem::Dependency
|
73
56
|
name: rspec
|
74
57
|
prerelease: false
|
75
|
-
requirement: &
|
58
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
76
59
|
none: false
|
77
60
|
requirements:
|
78
61
|
- - ~>
|
@@ -83,11 +66,11 @@ dependencies:
|
|
83
66
|
- 0
|
84
67
|
version: "2.0"
|
85
68
|
type: :development
|
86
|
-
version_requirements: *
|
69
|
+
version_requirements: *id003
|
87
70
|
- !ruby/object:Gem::Dependency
|
88
71
|
name: tilt
|
89
72
|
prerelease: false
|
90
|
-
requirement: &
|
73
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
91
74
|
none: false
|
92
75
|
requirements:
|
93
76
|
- - ~>
|
@@ -98,23 +81,22 @@ dependencies:
|
|
98
81
|
- 0
|
99
82
|
version: "1.0"
|
100
83
|
type: :development
|
101
|
-
version_requirements: *
|
84
|
+
version_requirements: *id004
|
102
85
|
- !ruby/object:Gem::Dependency
|
103
86
|
name: hoe
|
104
87
|
prerelease: false
|
105
|
-
requirement: &
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
106
89
|
none: false
|
107
90
|
requirements:
|
108
|
-
- -
|
91
|
+
- - ~>
|
109
92
|
- !ruby/object:Gem::Version
|
110
|
-
hash:
|
93
|
+
hash: 27
|
111
94
|
segments:
|
112
95
|
- 2
|
113
|
-
-
|
114
|
-
|
115
|
-
version: 2.9.1
|
96
|
+
- 12
|
97
|
+
version: "2.12"
|
116
98
|
type: :development
|
117
|
-
version_requirements: *
|
99
|
+
version_requirements: *id005
|
118
100
|
description: |-
|
119
101
|
RubyPython is a bridge between the Ruby and Python interpreters. It embeds a
|
120
102
|
running Python interpreter in the Ruby application's process using FFI and
|
@@ -178,6 +160,7 @@ files:
|
|
178
160
|
- spec/pymainclass_spec.rb
|
179
161
|
- spec/pyobject_spec.rb
|
180
162
|
- spec/python_helpers/basics.py
|
163
|
+
- spec/python_helpers/errors.py
|
181
164
|
- spec/python_helpers/objects.py
|
182
165
|
- spec/pythonerror_spec.rb
|
183
166
|
- spec/refcnt_spec.rb
|
@@ -186,7 +169,6 @@ files:
|
|
186
169
|
- spec/rubypython_spec.rb
|
187
170
|
- spec/spec_helper.rb
|
188
171
|
- .gemtest
|
189
|
-
has_rdoc: true
|
190
172
|
homepage:
|
191
173
|
licenses: []
|
192
174
|
|
@@ -217,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
199
|
requirements:
|
218
200
|
- Python, ~> 2.4
|
219
201
|
rubyforge_project: rubypython
|
220
|
-
rubygems_version: 1.
|
202
|
+
rubygems_version: 1.8.10
|
221
203
|
signing_key:
|
222
204
|
specification_version: 3
|
223
205
|
summary: RubyPython is a bridge between the Ruby and Python interpreters
|