[Python-Dev] [PATCH] fixing 2.5.1 build with unicode and dynamic loading disabled

2007-07-11 Thread Alexander Neundorf
Hi,

this is my first email to this list, I'm currently porting python to some 
platforms with limited capabilities and so I thought it would be a good idea 
to subscribe here.
While doing the porting, I found two small problems in Python 2.5.1:

If Py_USING_UNICODE is disabled, in Python/ast.c decode_unicode() still calls 
unicode-related functions, which leads to undefined references when linking.

If HAVE_DYNAMIC_LOADING is disabled, in Python/import.c 
_PyImport_DynLoadFiletab is still initialized, which also leads to undefined 
references when linking, since then no source file which defines this 
variable is used.

A patch against 2.5.1 is attached.

Best regards
Alex
diff -rbup Python-2.5.1-orig/Python/ast.c Python-2.5.1/Python/ast.c
--- Python-2.5.1-orig/Python/ast.c	2007-03-16 00:12:48.0 -0400
+++ Python-2.5.1/Python/ast.c	2007-07-10 17:06:00.0 -0400
@@ -3113,6 +3113,10 @@ decode_utf8(const char **sPtr, const cha
 static PyObject *
 decode_unicode(const char *s, size_t len, int rawmode, const char *encoding)
 {
+#ifndef Py_USING_UNICODE
+Py_FatalError(decode_unicode should not be called in this build.);
+return NULL;
+#else
 	PyObject *v, *u;
 	char *buf;
 	char *p;
@@ -3170,6 +3174,7 @@ decode_unicode(const char *s, size_t len
 		v = PyUnicode_DecodeUnicodeEscape(s, len, NULL);
 	Py_XDECREF(u);
 	return v;
+#endif
 }
 
 /* s is a Python string literal, including the bracketing quote characters,
diff -rbup Python-2.5.1-orig/Python/import.c Python-2.5.1/Python/import.c
--- Python-2.5.1-orig/Python/import.c	2007-03-13 19:04:29.0 -0400
+++ Python-2.5.1/Python/import.c	2007-07-10 17:02:25.0 -0400
@@ -117,15 +117,20 @@ _PyImport_Init(void)
 	/* prepare _PyImport_Filetab: copy entries from
 	   _PyImport_DynLoadFiletab and _PyImport_StandardFiletab.
 	 */
+#ifdef HAVE_DYNAMIC_LOADING
 	for (scan = _PyImport_DynLoadFiletab; scan-suffix != NULL; ++scan)
 		++countD;
+#endif
+
 	for (scan = _PyImport_StandardFiletab; scan-suffix != NULL; ++scan)
 		++countS;
 	filetab = PyMem_NEW(struct filedescr, countD + countS + 1);
 	if (filetab == NULL)
 		Py_FatalError(Can't initialize import file table.);
+#ifdef HAVE_DYNAMIC_LOADING
 	memcpy(filetab, _PyImport_DynLoadFiletab,
 	   countD * sizeof(struct filedescr));
+#endif
 	memcpy(filetab + countD, _PyImport_StandardFiletab,
 	   countS * sizeof(struct filedescr));
 	filetab[countD + countS].suffix = NULL;
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [PATCH] fixing 2.5.1 build with unicode and dynamic loading disabled

2007-07-11 Thread Alexander Neundorf
On Wednesday 11 July 2007 15:01, Aahz wrote:
 On Wed, Jul 11, 2007, Alexander Neundorf wrote:
  A patch against 2.5.1 is attached.

 Patches to the list tend to get lost.  Please post to SourceForge and
 then send the ID to python-dev.

Done, it's #1752175

Alex
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com