lucene-pylucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject svn commit: r1800078 - /lucene/pylucene/trunk/jcc/jcc3/python.py
Date Tue, 27 Jun 2017 16:56:56 GMT
Author: vajda
Date: Tue Jun 27 16:56:56 2017
New Revision: 1800078

URL: http://svn.apache.org/viewvc?rev=1800078&view=rev
Log:
 - removed unnecessary u in front of generated "
 - switched to PyObject_SetAttrString to set descriptors on type objects

Modified:
    lucene/pylucene/trunk/jcc/jcc3/python.py

Modified: lucene/pylucene/trunk/jcc/jcc3/python.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc3/python.py?rev=1800078&r1=1800077&r2=1800078&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc3/python.py (original)
+++ lucene/pylucene/trunk/jcc/jcc3/python.py Tue Jun 27 16:56:56 2017
@@ -1054,14 +1054,14 @@ def python(env, out_h, out, cls, superCl
         if inner in typeset:
             if Modifier.isStatic(inner.getModifiers()):
                 innerName = inner.getName().split('.')[-1]
-                line(out, indent + 1, 'PyDict_SetItemString(PY_TYPE(%s)->tp_dict, "%s",
make_descriptor(&PY_TYPE_DEF(%s)));',
+                line(out, indent + 1, 'PyObject_SetAttrString((PyObject *) PY_TYPE(%s), "%s",
make_descriptor(&PY_TYPE_DEF(%s)));',
                      names[-1], innerName[len(names[-1])+1:], innerName)
     line(out, indent, '}')
 
     line(out)
     line(out, indent, 'void t_%s::initialize(PyObject *module)', names[-1])
     line(out, indent, '{')
-    line(out, indent + 1, 'PyDict_SetItemString(PY_TYPE(%s)->tp_dict, "class_", make_descriptor(%s::initializeClass,
%s));',
+    line(out, indent + 1, 'PyObject_SetAttrString((PyObject *) PY_TYPE(%s), "class_", make_descriptor(%s::initializeClass,
%s));',
          names[-1], cppname(names[-1]), generics and 1 or 0)
 
     if is_unboxed(cls.getName()):
@@ -1071,8 +1071,8 @@ def python(env, out_h, out, cls, superCl
         wrapfn_ = "t_%s::wrap_jobject" %(names[-1])
         boxfn_ = "boxObject"
 
-    line(out, indent + 1, 'PyDict_SetItemString(PY_TYPE(%s)->tp_dict, "wrapfn_", make_descriptor(%s));',
names[-1], wrapfn_)
-    line(out, indent + 1, 'PyDict_SetItemString(PY_TYPE(%s)->tp_dict, "boxfn_", make_descriptor(%s));',
names[-1], boxfn_)
+    line(out, indent + 1, 'PyObject_SetAttrString((PyObject *) PY_TYPE(%s), "wrapfn_", make_descriptor(%s));',
names[-1], wrapfn_)
+    line(out, indent + 1, 'PyObject_SetAttrString((PyObject *) PY_TYPE(%s), "boxfn_", make_descriptor(%s));',
names[-1], boxfn_)
 
     if isExtension:
         line(out, indent + 1, 'jclass cls = env->getClass(%s::initializeClass);',
@@ -1101,7 +1101,7 @@ def python(env, out_h, out, cls, superCl
             cppFieldName += RENAME_FIELD_SUFFIX
         value = '%s::%s' %(cppname(names[-1]), cppFieldName)
         value = fieldValue(cls, value, fieldType)
-        line(out, indent + 1, 'PyDict_SetItemString(PY_TYPE(%s)->tp_dict, "%s", make_descriptor(%s));',
+        line(out, indent + 1, 'PyObject_SetAttrString((PyObject *) PY_TYPE(%s), "%s", make_descriptor(%s));',
              names[-1], fieldName, value)
     line(out, indent, '}')
 
@@ -1693,7 +1693,7 @@ def compile(env, jccPath, output, module
     line(out, 1, 'def __str__(self):')
     line(out, 2, 'writer = StringWriter()')
     line(out, 2, 'self.getJavaException().printStackTrace(PrintWriter(writer))')
-    line(out, 2, 'return u"\\n".join((str(super(JavaError, self)), u"    Java stacktrace:",
str(writer)))')
+    line(out, 2, 'return "\\n".join((str(super(JavaError, self)), "    Java stacktrace:",
str(writer)))')
     line(out)
     line(out, 0, 'class InvalidArgsError(Exception):')
     line(out, 1, 'pass')



Mime
View raw message