pycall 1.0.1-x86-mingw32 → 1.0.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 180214067ddcaf79661c66115fff03746377e8df
4
- data.tar.gz: cc52f4b1a14b7b404aac141accbe7c59cecb5fcf
3
+ metadata.gz: f5a2a91419949c2e7d9186d8a0c5692060be86fe
4
+ data.tar.gz: a4db37e6cb6216491c3c40fd3e9487218217c2c4
5
5
  SHA512:
6
- metadata.gz: c007c0aba62d54a1078df393c67e989c49acaaff3f6c11f8ec46c84a01fb455c4cf10e546df1daaf84c52e0cfe504fa00911525fe2dd21f92f0a46d9c6ddf649
7
- data.tar.gz: db164125165d7d53fb85d64b0ba050e05051b70fcf00b1417229bc359488dc97fc01b4fef229d50292637e13a844d7ee58f8aa3962caca747d99c9b1b394274b
6
+ metadata.gz: ef09266b2492e13257ca7a184c2f68c7f759937178578fbc2fa27f17e765e9345c19a48cac187a4c8efe6e6ccf42896acf2ef436e4be15e253f699c07707cf74
7
+ data.tar.gz: 774ccc839e27b54ae46877c10f48edd0a44136b8854a00f0fbed9cc0a7b0f5d66d70bc3de4dfc9ce3c8ece59d9b1034650d383f71710b846c3da7dc50e1c88fe
data/.travis.yml CHANGED
@@ -12,9 +12,9 @@ env:
12
12
  global:
13
13
  - PYCALL_DEBUG_FIND_LIBPYTHON=1
14
14
  matrix:
15
- - PYTHON=python
16
- - PYTHON=python3 LIBPYTHON=wrong_value
17
- - LIBPYTHON=/opt/python/3.5.3/lib/libpython3.5m.so
15
+ - PYTHON=python PYENV_VERSION=system
16
+ - PYTHON=python3 PYENV_VERSION=3.5.3 LIBPYTHON=wrong_value
17
+ - PYENV_VERSION=3.5.3 LIBPYTHON=/opt/python/3.5.3/lib/libpython3.5m.so
18
18
 
19
19
  addons:
20
20
  apt:
@@ -33,8 +33,8 @@ before_script:
33
33
  - echo === python investigator.py ===
34
34
  - python lib/pycall/python/investigator.py
35
35
  - python3 lib/pycall/python/investigator.py
36
- - pip install numpy
37
- - pip3 install numpy
36
+ - travis_retry pip install --user numpy
37
+ - PYENV_VERSION=3.5.3 travis_retry pip3 install --user numpy
38
38
 
39
39
  matrix:
40
40
  allow_failures:
data/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # The change history of PyCall
2
2
 
3
+ ## 1.0.2
4
+
5
+ * Fix the bug that a large Python string is broken when it converted to Ruby string
6
+ https://github.com/mrkn/pycall.rb/issues/32
7
+
3
8
  ## 1.0.1
4
9
 
5
10
  * Add PyTypeObject#===.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # PyCall: Calling Python functions from the Ruby language
2
2
 
3
- [![Build Status](https://travis-ci.org/mrkn/pycall.svg?branch=master)](https://travis-ci.org/mrkn/pycall)
4
- [![Build status](https://ci.appveyor.com/api/projects/status/071is0f4iu0vy8lp/branch/master?svg=true)](https://ci.appveyor.com/project/mrkn/pycall/branch/master)
3
+ [![Build Status](https://travis-ci.org/mrkn/pycall.rb.svg?branch=1.0)](https://travis-ci.org/mrkn/pycall.rb)
4
+ [![Build status](https://ci.appveyor.com/api/projects/status/naw56ldru71w7qsw/branch/1.0?svg=true)](https://ci.appveyor.com/project/mrkn/pycall-rb/branch/1.0)
5
5
 
6
6
  This library provides the features to directly call and partially interoperate
7
7
  with Python from the Ruby language. You can import arbitrary Python modules
@@ -77,7 +77,7 @@ version, push git commits and tags, and push the `.gem` file to
77
77
  ## Contributing
78
78
 
79
79
  Bug reports and pull requests are welcome on GitHub at
80
- https://github.com/mrkn/pycall.
80
+ https://github.com/mrkn/pycall.rb.
81
81
 
82
82
 
83
83
  ## Acknowledgement
data/ext/pycall/pycall.c CHANGED
@@ -1,4 +1,5 @@
1
1
  #include "pycall_internal.h"
2
+ #include <ruby/encoding.h>
2
3
 
3
4
  #include <stdarg.h>
4
5
 
@@ -1317,7 +1318,10 @@ pycall_pyobject_to_ruby(PyObject *pyobj)
1317
1318
  if (pyobj->ob_type == Py_API(PyLong_Type))
1318
1319
  return pycall_pylong_to_ruby(pyobj);
1319
1320
 
1320
- if (pyobj->ob_type == Py_API(PyUnicode_Type) || pyobj->ob_type == Py_API(PyString_Type))
1321
+ if (pyobj->ob_type == Py_API(PyUnicode_Type))
1322
+ return pycall_pyunicode_to_ruby(pyobj);
1323
+
1324
+ if (pyobj->ob_type == Py_API(PyString_Type))
1321
1325
  return pycall_pystring_to_ruby(pyobj);
1322
1326
 
1323
1327
  Py_API(Py_IncRef)(pyobj);
@@ -1469,24 +1473,46 @@ pycall_pystring_to_ruby(PyObject *pyobj)
1469
1473
  {
1470
1474
  char *str = NULL;
1471
1475
  Py_ssize_t len = 0;
1472
- int res = -1;
1476
+ int res;
1477
+
1478
+ /* TODO: PyString_Check */
1479
+ if (pyobj->ob_type != Py_API(PyString_Type)) {
1480
+ return Qnil;
1481
+ }
1482
+
1483
+ res = Py_API(PyString_AsStringAndSize)(pyobj, &str, &len);
1484
+ if (res < 0) {
1485
+ return Qnil;
1486
+ }
1487
+
1488
+ return rb_enc_str_new(str, len, rb_enc_from_index(rb_ascii8bit_encindex()));
1489
+ }
1490
+
1491
+ VALUE
1492
+ pycall_pyunicode_to_ruby(PyObject *pyobj)
1493
+ {
1494
+ char *str = NULL;
1495
+ Py_ssize_t len = 0;
1496
+ int res;
1473
1497
 
1474
1498
  /* TODO: PyUnicode_Check */
1475
- if (pyobj->ob_type == Py_API(PyUnicode_Type)) {
1476
- pyobj = Py_API(PyUnicode_AsUTF8String)(pyobj);
1477
- res = Py_API(PyString_AsStringAndSize)(pyobj, &str, &len);
1478
- pycall_Py_DecRef(pyobj);
1499
+ if (pyobj->ob_type != Py_API(PyUnicode_Type)) {
1500
+ return Qnil;
1479
1501
  }
1480
- /* TODO: PyString_Check */
1481
- else if (pyobj->ob_type == Py_API(PyString_Type)) {
1482
- res = Py_API(PyString_AsStringAndSize)(pyobj, &str, &len);
1502
+
1503
+ pyobj = Py_API(PyUnicode_AsUTF8String)(pyobj);
1504
+ if (!pyobj) {
1505
+ Py_API(PyErr_Clear)();
1506
+ return Qnil;
1483
1507
  }
1484
1508
 
1509
+ res = Py_API(PyString_AsStringAndSize)(pyobj, &str, &len);
1485
1510
  if (res < 0) {
1511
+ pycall_Py_DecRef(pyobj);
1486
1512
  return Qnil;
1487
1513
  }
1488
1514
 
1489
- return rb_str_new(str, len);
1515
+ return rb_enc_str_new(str, len, rb_enc_from_index(rb_utf8_encindex()));
1490
1516
  }
1491
1517
 
1492
1518
  static VALUE
@@ -646,6 +646,7 @@ VALUE pycall_pyfloat_to_ruby(PyObject *);
646
646
  VALUE pycall_pyint_to_ruby(PyObject *);
647
647
  VALUE pycall_pylong_to_ruby(PyObject *);
648
648
  VALUE pycall_pystring_to_ruby(PyObject *);
649
+ VALUE pycall_pyunicode_to_ruby(PyObject *);
649
650
  VALUE pycall_pyobject_to_a(PyObject *);
650
651
 
651
652
  VALUE pycall_conv_to_str(VALUE);
data/lib/2.1/pycall.so CHANGED
Binary file
data/lib/2.2/pycall.so CHANGED
Binary file
data/lib/2.3/pycall.so CHANGED
Binary file
data/lib/2.4/pycall.so CHANGED
Binary file
@@ -5,21 +5,19 @@ module PyCall
5
5
  module IRubyHelper
6
6
  private
7
7
 
8
- def check_pyobject_respond_to_format_method(obj, method_name)
9
- return false unless obj.kind_of? PyObject
10
- return false unless PyCall.hasattr?(obj, method_name)
11
- PyCall.getattr(obj, method_name).kind_of? PyCall::LibPython.PyMethod_Type
8
+ def check_python_object_respond_to_format_method(obj, method_name)
9
+ return false unless obj.kind_of? PyObjectWrapper
10
+ return false unless obj.respond_to? method_name
11
+ true
12
12
  end
13
13
 
14
- def register_pyobject_formatter(format_name, mime, priority_value=0)
14
+ def register_python_object_formatter(format_name, mime, priority_value=0)
15
15
  method_name = :"_repr_#{format_name}_"
16
16
  match do |obj|
17
- check_pyobject_respond_to_format_method(obj, method_name)
17
+ check_python_object_respond_to_format_method(obj, method_name)
18
18
  end
19
19
  priority priority_value
20
- format mime do |obj|
21
- PyCall.getattr(obj, method_name).()
22
- end
20
+ format mime, &method_name
23
21
  end
24
22
  end
25
23
  end
@@ -27,14 +25,14 @@ end
27
25
  ::IRuby::Display::Registry.module_eval do
28
26
  extend PyCall::IRubyHelper
29
27
 
30
- register_pyobject_formatter :html, 'text/html'
31
- register_pyobject_formatter :markdown, 'text/markdown'
32
- register_pyobject_formatter :svg, 'image/svg+xml'
33
- register_pyobject_formatter :png, 'image/png'
34
- register_pyobject_formatter :jpeg, 'image/jpeg'
35
- register_pyobject_formatter :latex, 'text/latex'
36
- register_pyobject_formatter :json, 'application/json'
37
- register_pyobject_formatter :javascript, 'application/javascript'
38
- register_pyobject_formatter :pdf, 'application/pdf'
39
- register_pyobject_formatter :pretty, 'text/plain', -1000
28
+ register_python_object_formatter :html, 'text/html', 1
29
+ register_python_object_formatter :markdown, 'text/markdown', 1
30
+ register_python_object_formatter :svg, 'image/svg+xml', 1
31
+ register_python_object_formatter :png, 'image/png', 1
32
+ register_python_object_formatter :jpeg, 'image/jpeg', 1
33
+ register_python_object_formatter :latex, 'text/latex', 1
34
+ register_python_object_formatter :json, 'application/json', 1
35
+ register_python_object_formatter :javascript, 'application/javascript', 1
36
+ register_python_object_formatter :pdf, 'application/pdf', 1
37
+ register_python_object_formatter :pretty, 'text/plain', -1000
40
38
  end
@@ -1,3 +1,3 @@
1
1
  module PyCall
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
data/lib/pycall.rb CHANGED
@@ -89,3 +89,5 @@ module PyCall
89
89
  end
90
90
  end
91
91
  end
92
+
93
+ require 'pycall/iruby_helper' if defined? IRuby
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pycall
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Kenta Murata
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-08 00:00:00.000000000 Z
11
+ date: 2017-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler