[python-admesh] 01/04: Fix python3 binding.

Anton Gladky gladk at moszumanska.debian.org
Sat Aug 30 20:09:17 UTC 2014


This is an automated email from the git hooks/post-receive script.

gladk pushed a commit to branch master
in repository python-admesh.

commit 32a4c6ca44b41b8a6f917cc4ae42929546477586
Author: Anton Gladky <gladk at debian.org>
Date:   Fri Aug 29 23:13:21 2014 +0200

    Fix python3 binding.
---
 debian/.copyright.swp            | Bin 12288 -> 0 bytes
 debian/patches/fix_python3.patch |  61 +++++++++++++++++++++++++++++++++++++++
 debian/patches/series            |   1 +
 3 files changed, 62 insertions(+)

diff --git a/debian/.copyright.swp b/debian/.copyright.swp
deleted file mode 100644
index 1410a51..0000000
Binary files a/debian/.copyright.swp and /dev/null differ
diff --git a/debian/patches/fix_python3.patch b/debian/patches/fix_python3.patch
new file mode 100644
index 0000000..16e4324
--- /dev/null
+++ b/debian/patches/fix_python3.patch
@@ -0,0 +1,61 @@
+From 1c68df8125fb1d8d292542f03f494dc184d77dc8 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro at hroncok.cz>
+Date: Fri, 29 Aug 2014 19:53:43 +0200
+Subject: [PATCH] Always encode given string before passing it to admesh
+
+Fixes #1
+---
+ _admesh.pyx |  3 ++-
+ autogen.py  | 10 ++++++++++
+ 2 files changed, 12 insertions(+), 1 deletion(-)
+
+diff --git a/_admesh.pyx b/_admesh.pyx
+index cc8b0e5..01db6eb 100644
+--- a/_admesh.pyx
++++ b/_admesh.pyx
+@@ -22,7 +22,8 @@ cdef class Stl:
+ 
+     def open(self, path):
+         """stl_open"""
+-        stl_open(&self._c_stl_file, path)
++        by_path = path.encode('UTF-8')
++        stl_open(&self._c_stl_file, by_path)
+         if stl_get_error(&self._c_stl_file):
+             stl_clear_error(&self._c_stl_file)
+             raise AdmeshError('stl_open')
+diff --git a/autogen.py b/autogen.py
+index fa137f8..da14d0e 100644
+--- a/autogen.py
++++ b/autogen.py
+@@ -79,7 +79,9 @@ def autogen(self):
+                 if static:
+                     continue # this is a hack, we don' want any static method NOW
+                 args = []
++                chars = set()
+                 for arg in line:
++                    char = arg.split()[-2]
+                     arg = arg.split()[-1]
+                     if arg.startswith('*'):
+                         arg = arg[1:]
+@@ -88,6 +90,8 @@ def autogen(self):
+                     if arg.endswith('[3]'):
+                         arg = arg[:-3]
+                     args.append(arg)
++                    if char == 'char':
++                        chars.add(arg)
+                 if static:
+                     pyxlines.append('    @classmethod\n')
+                 pyxlines.append('    def ')
+@@ -114,6 +118,12 @@ def autogen(self):
+                 pyxlines.append('"""')
+                 pyxlines.append('\n        if not self._opened:')
+                 pyxlines.append('\n            raise AdmeshError(\'STL not opened\')')
++                for idx, arg in enumerate(args):
++                    if arg not in chars:
++                        continue
++                    pyxlines.append('\n        ')
++                    pyxlines.append('by_{arg} = {arg}.encode(\'UTF-8\')'.format(arg=arg))
++                    args[idx] = 'by_' + arg
+                 pyxlines.append('\n        ')
+                 pyxlines.append(PREFIX+function)
+                 pyxlines.append('(')
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..01c09fc
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+fix_python3.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-admesh.git



More information about the debian-science-commits mailing list