Paulo Levi | 12 Mar 2011 13:01
Picon

Porting 2.1 to 2.7 without source

There is a rather old game, "Vampire the Masquerade: Bloodlines" that used a cut down python 2.1 for scripts. I am trying (and failing) to port it to a more complete python version, and thought 2.7 would be a nice target being the last same major version.

Well, anyway, i only need to add 3 missing functions (troika original), expose "void _PyObject_Del(PyObject *op)" that appears to have been hidden around 2.3, set a new home based on the dll path and the game starts up (full of errors of course).

One error in special is bothering me, since it appears to be caused by changes to the PyTypeObject struct. Whenever one of the "cvar" objects that troika binded to the half life 2 engine gets to a certain level of the scripting engine, a pagefault is almost inevitable. These happen in the "PyType_Ready(PyTypeObject *type)" function for the base class (that bizarrely appears neither to be PyBaseObject_Type or NULL, but 8), and when adding methods to the dict, and i stopped trying to fix it there here.

Strangely tp_name is "cvar" as expected.


Is this a impossible dream?

_______________________________________________
Python-porting mailing list
Python-porting@...
http://mail.python.org/mailman/listinfo/python-porting
Lennart Regebro | 12 Mar 2011 19:46
Picon
Gravatar

Re: Porting 2.1 to 2.7 without source

On Sat, Mar 12, 2011 at 07:01, Paulo Levi <i30817@...> wrote:
> One error in special is bothering me, since it appears to be caused by
> changes to the PyTypeObject struct. Whenever one of the "cvar" objects that
> troika binded to the half life 2 engine gets to a certain level of the
> scripting engine, a pagefault is almost inevitable.

Wild guess: Could this have something to do with the changes to
conform with aliasing rules?

http://www.python.org/dev/peps/pep-3123/
Paulo Levi | 12 Mar 2011 23:47
Picon

Re: Porting 2.1 to 2.7 without source

Well, i just used python source 2.1.3 (supposedly one minor version above what troika used, and the same problem occurs though probably not on the same place (i haven't bothered to track it down here, since it doesn't occur on typeobject.c anymore). Anyway to disable that optimization in visual studio c++ 6.0 to be sure it's not that?

On Sat, Mar 12, 2011 at 6:46 PM, Lennart Regebro <regebro <at> gmail.com> wrote:
On Sat, Mar 12, 2011 at 07:01, Paulo Levi <i30817-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> One error in special is bothering me, since it appears to be caused by
> changes to the PyTypeObject struct. Whenever one of the "cvar" objects that
> troika binded to the half life 2 engine gets to a certain level of the
> scripting engine, a pagefault is almost inevitable.

Wild guess: Could this have something to do with the changes to
conform with aliasing rules?

http://www.python.org/dev/peps/pep-3123/

_______________________________________________
Python-porting mailing list
Python-porting@...
http://mail.python.org/mailman/listinfo/python-porting
Paulo Levi | 13 Mar 2011 05:26
Picon

Re: Porting 2.1 to 2.7 without source

Also a interesting incompatibility occurred that i've just noticed. The game didn't recognize the bool type as a int (as it expected the expression) although bool is a subtype of int.

When i put this in PyRun_String that went away:

            r = PyRun_StringFlags(str, s, g, l, NULL);
            if(r != NULL && PyBool_Check(r)){
                if(r == Py_True)
                    return PyInt_FromLong(1L);
                else
                    return PyInt_FromLong(0L);
            }
            return r;

_______________________________________________
Python-porting mailing list
Python-porting@...
http://mail.python.org/mailman/listinfo/python-porting
Lennart Regebro | 13 Mar 2011 12:44
Picon
Gravatar

Re: Porting 2.1 to 2.7 without source

On Sat, Mar 12, 2011 at 17:47, Paulo Levi <i30817@...> wrote:
> Well, i just used python source 2.1.3 (supposedly one minor version above
> what troika used, and the same problem occurs though probably not on the
> same place (i haven't bothered to track it down here, since it doesn't occur
> on typeobject.c anymore). Anyway to disable that optimization in visual
> studio c++ 6.0 to be sure it's not that?

I don't know, but you can change

    PyObject_HEAD_INIT(NULL)
    0, /* ob_size */

to

    PyVarObject_HEAD_INIT(NULL, 0)

That won't work on Python 2.5 or earlier, but it should work under
Python 2.6 and 2.7. I don't have any real reason to believe this to be
the problem, but it could be worth a try.
Paulo Levi | 14 Mar 2011 06:46
Picon

Re: Porting 2.1 to 2.7 without source

I'm confused. Isn't that only possible if you can control the source (or have enough debugging skill)? I don't actually have a compilable form of the source for the c extension, and i only see those structs initializations on them.

On Sun, Mar 13, 2011 at 11:44 AM, Lennart Regebro <regebro <at> gmail.com> wrote:
On Sat, Mar 12, 2011 at 17:47, Paulo Levi <i30817-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Well, i just used python source 2.1.3 (supposedly one minor version above
> what troika used, and the same problem occurs though probably not on the
> same place (i haven't bothered to track it down here, since it doesn't occur
> on typeobject.c anymore). Anyway to disable that optimization in visual
> studio c++ 6.0 to be sure it's not that?

I don't know, but you can change

   PyObject_HEAD_INIT(NULL)
   0, /* ob_size */

to

   PyVarObject_HEAD_INIT(NULL, 0)

That won't work on Python 2.5 or earlier, but it should work under
Python 2.6 and 2.7. I don't have any real reason to believe this to be
the problem, but it could be worth a try.

_______________________________________________
Python-porting mailing list
Python-porting@...
http://mail.python.org/mailman/listinfo/python-porting
Lennart Regebro | 14 Mar 2011 10:44
Picon
Gravatar

Re: Porting 2.1 to 2.7 without source

On Mon, Mar 14, 2011 at 01:46, Paulo Levi <i30817@...> wrote:
> I'm confused. Isn't that only possible if you can control the source (or
> have enough debugging skill)? I don't actually have a compilable form of the
> source for the c extension, and i only see those structs initializations on
> them.

I'm sorry, I didn't take the "without source" comment seriously in
your topic, because that is obviously impossible. I thought you meant
something else. You can not support any new Python version without the
C-extensions source. It needs to be recompiled.

--

-- 
Lennart Regebro: http://regebro.wordpress.com/
Python 3 Porting book: http://python3porting.com/
+33 661 58 14 64

Gmane