Marc-Andre Lemburg <m...@egenix.com> added the comment:

Ezio Melotti wrote:
> 
> Ezio Melotti <ezio.melo...@gmail.com> added the comment:
> 
> The attached patch skips the peepholer optimizations for BINARY_SUBSCR if the 
> resulting char is a surrogate on narrow builds or a non-bmp char in wide 
> builds.
> Note that this affects the optimization of lone surrogates on narrow builds 
> too, but I think it's not worth to adding more complexity on the peepholer 
> and check if they are part of a surrogate pair.
> The patch still lacks comments and could have better tests.

             newconst = PyObject_GetItem(v, w);
+            if (PyUnicode_Check(v)) {
+                Py_UNICODE ch = PyUnicode_AS_UNICODE(newconst)[0];

Without checking, you shouldn't assume that newconst is a PyUnicodeObject.

Other than that the patch looks fine.

----------
nosy: +lemburg
title: Unicode-width dependent optimization leads to non-portable pyc file -> 
Unicode-width dependent optimization leads to     non-portable pyc file

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5057>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to