[issue28598] RHS not consulted in `str % subclass_of_str` case.

2016-11-03 Thread Xiang Zhang
Changes by Xiang Zhang : -- nosy: +xiang.zhang ___ Python tracker <http://bugs.python.org/issue28598> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue28563] Arbitrary code execution in gettext.c2py

2016-11-03 Thread Xiang Zhang
Xiang Zhang added the comment: gettext_c2py.patch tries to avoid the problem. It still uses eval but manually parse the expression using tokens extracted from gettext. Tests are passed. But there is still a problem. Both patched and original c2py fail to handle nested ternary operator. They

[issue28580] Optimize iterating split table values

2016-11-04 Thread Xiang Zhang
Xiang Zhang added the comment: Thanks! -- ___ Python tracker <http://bugs.python.org/issue28580> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue28199] Compact dict resizing is doing too much work

2016-11-04 Thread Xiang Zhang
Xiang Zhang added the comment: #28580 and #28583 are resolved now. I think dictresize4 can be recommited now. -- stage: needs patch -> commit review ___ Python tracker <http://bugs.python.org/issu

[issue28563] Arbitrary code execution in gettext.c2py

2016-11-05 Thread Xiang Zhang
Xiang Zhang added the comment: > gettext.c2py("n()")(lambda: os.system("sh")) > gettext.c2py("1()")(0) Empty parentheses should be disallowed. Function calls are not allowed in plural expression. And non-integer argument should be disallowed either, just a

[issue28563] Arbitrary code execution in gettext.c2py

2016-11-05 Thread Xiang Zhang
Xiang Zhang added the comment: > '1?2:3?4:5' -> '(2 if 1 else 3)?4:5' -> '(4 if (2 if 1 else 3) else 5' This is not right. It's right associative so it should be 1?2:(3?4:5) -> 1?2:(4 if 3 else 5) -> 2 if 1 else (4 if 3 else 5) > It woul

[issue28620] Build Memory Leak

2016-11-05 Thread Xiang Zhang
Xiang Zhang added the comment: This seems a same problem as in #27780. -- nosy: +xiang.zhang ___ Python tracker <http://bugs.python.org/issue28620> ___ ___ Pytho

[issue28563] Arbitrary code execution in gettext.c2py

2016-11-05 Thread Xiang Zhang
Xiang Zhang added the comment: Christian, I think our patches are quite similar in function. They only allow limited tokens. > I consider it a superior solution and a fix for more generic attacks Mine now still allows **. But it can be easily fixed. But both our patches still translate

[issue28563] Arbitrary code execution in gettext.c2py

2016-11-06 Thread Xiang Zhang
Xiang Zhang added the comment: gettext_c2py_v2.patch implements a simple C expression parser. More tests are included. Carl, hope you are willing to test it. -- Added file: http://bugs.python.org/file45373/gettext_c2py_v2.patch ___ Python tracker

[issue28398] Return singleton empty string in _PyUnicode_FromASCII

2016-11-06 Thread Xiang Zhang
Xiang Zhang added the comment: IMHO, _PyUnicode_FromASCII is a private API and could be used in other places in future. We should not rely on the caller to check and return the singleton empty string. -- ___ Python tracker <http://bugs.python.

[issue28563] Arbitrary code execution in gettext.c2py

2016-11-07 Thread Xiang Zhang
Xiang Zhang added the comment: > Perhaps it should give a DeprectationWarning and delegate to _Plural? I hold a conservative opinion about this. c2py in my mind should be a inner help method. It's not documented so if there are users using it, they are risking changes. And as repor

[issue28563] Arbitrary code execution in gettext.c2py

2016-11-07 Thread Xiang Zhang
Xiang Zhang added the comment: > Sorry Xiang, but your patch looks overcomplicated to me. Too much methods, > decorators, classes, too much strange names. It's fine. That's a Pratt parser. Yes, the names are strange. Your patch looks more simpler. I left

[issue28638] Creating namedtuple is too slow to be used in common stdlib (e.g. functools)

2016-11-07 Thread Xiang Zhang
Xiang Zhang added the comment: I doubt this deserves a change. The slow import is the case only the first time functools is imported. Later imports will just use the cache (sys.modules). And if this is gonna change, maybe we don't have to copy the entire namedtuple structure? --

[issue28638] Creating namedtuple is too slow to be used in common stdlib (e.g. functools)

2016-11-07 Thread Xiang Zhang
Changes by Xiang Zhang : -- nosy: +ncoghlan, rhettinger ___ Python tracker <http://bugs.python.org/issue28638> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue28638] Creating namedtuple is too slow to be used in common stdlib (e.g. functools)

2016-11-07 Thread Xiang Zhang
Xiang Zhang added the comment: > Yes. But first import time is also important for CLI applications. That's why mercurial and Bazaar has lazy import system. The lazy import system could benefit many libs so the result could be impressive. But here only functools is enhanced, half a mil

[issue28563] Arbitrary code execution in gettext.c2py

2016-11-08 Thread Xiang Zhang
Xiang Zhang added the comment: LGTM. And I expect there could be a comment about the special decimal number. -- ___ Python tracker <http://bugs.python.org/issue28

[issue28563] Arbitrary code execution in gettext.c2py

2016-11-08 Thread Xiang Zhang
Xiang Zhang added the comment: > What a comment you need Xiang? Isn't existing comment enough? Serhiy, I mean the case a number starting with 0, e.g. 0123. The plural form is a C expression and in C 0123 is an octal number. c2py now interprets it as a decima

[issue20629] Python ctypes BigEndianStructure bitfield assignment misbehavior in Linux

2016-11-08 Thread Xiang Zhang
Xiang Zhang added the comment: The bug is fixed in #23319. More recent Py2.7 and Py3.4+ should get rid of it. -- nosy: +xiang.zhang resolution: -> fixed stage: -> resolved status: open -> closed ___ Python tracker <http://bug

[issue28648] False assert in _Py_DecodeUTF8_surrogateescape

2016-11-09 Thread Xiang Zhang
New submission from Xiang Zhang: The assert statement `assert(Py_UNICODE_IS_SURROGATE(ch));` in _Py_DecodeUTF8_surrogateescape is wrong. Code points > 0x could reach it and fail. -- files: false_assert.patch keywords: patch messages: 280406 nosy: serhiy.storchaka, xiang.zh

[issue24329] __qualname__ and __slots__

2016-11-09 Thread Xiang Zhang
Xiang Zhang added the comment: Why should it work Yury? __qualname__ and __doc__(if exists) are inserted into the dict when creating a class. >>> class Foo: ... """bar""" ... __slots__ = ('__doc__',) ... Traceback (most recent call l

[issue24329] __qualname__ and __slots__

2016-11-09 Thread Xiang Zhang
Changes by Xiang Zhang : -- keywords: +patch stage: -> patch review type: -> behavior Added file: http://bugs.python.org/file45420/slots_qualname.patch ___ Python tracker <http://bugs.python.org/i

[issue24329] __qualname__ and __slots__

2016-11-10 Thread Xiang Zhang
Xiang Zhang added the comment: I think of them but currently they don't pose a problem for practical codes like __qualname__. Maybe leaving them until there comes a real need? -- ___ Python tracker <http://bugs.python.org/is

[issue24329] __qualname__ and __slots__

2016-11-10 Thread Xiang Zhang
Changes by Xiang Zhang : Added file: http://bugs.python.org/file45421/slots_qualname_v2.patch ___ Python tracker <http://bugs.python.org/issue24329> ___ ___ Python-bug

[issue24329] __qualname__ and __slots__

2016-11-10 Thread Xiang Zhang
Xiang Zhang added the comment: > What about other names set when creating a class? __module__, __class__, > __classcell__? __module__ remains in the class dict so I think it's a class variable. Will __class__ be set? It's inserted into the function scope. __classcell__ I th

[issue24329] __qualname__ and __slots__

2016-11-10 Thread Xiang Zhang
Xiang Zhang added the comment: slots_special_v2 fixes a bug in the previous patch. -- Added file: http://bugs.python.org/file45425/slots_special_v2.patch ___ Python tracker <http://bugs.python.org/issue24

[issue28659] xml.etree.cElementTree.write misses opening tag

2016-11-10 Thread Xiang Zhang
Xiang Zhang added the comment: is an empty tag. It closes it self, not '/>'. With some content, you can see it has start and end tag. >>> import xml.etree.cElementTree as ET >>> events = ET.Element('Events') >>> events.text = 'abc'

[issue28659] xml.etree.cElementTree.write misses opening tag

2016-11-10 Thread Xiang Zhang
Xiang Zhang added the comment: s/not/note -- ___ Python tracker <http://bugs.python.org/issue28659> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue24329] __qualname__ and __slots__

2016-11-11 Thread Xiang Zhang
Xiang Zhang added the comment: v3 updates the test cases. -- Added file: http://bugs.python.org/file45444/slots_special_v3.patch ___ Python tracker <http://bugs.python.org/issue24

[issue28679] CGIHTTPServer displays raw python code when the url contains '/' after '?'

2016-11-13 Thread Xiang Zhang
Xiang Zhang added the comment: Sorry Yudai, I cannot reproduce this. Both '/index.py?value=data' and '/index.py?/' outputs 'value = None' with your index.py. -- nosy: +martin.panter, xiang.zhang ___ Python tracker <

[issue28679] CGIHTTPServer displays raw python code when the url contains '/' after '?'

2016-11-13 Thread Xiang Zhang
Xiang Zhang added the comment: I think this is a bug in 2.7.5 and has already been fixed. I'd suggest you get a more recent version of 2.7. :-) -- ___ Python tracker <http://bugs.python.org/is

[issue28679] CGIHTTPServer displays raw python code when the url contains '/' after '?'

2016-11-13 Thread Xiang Zhang
Changes by Xiang Zhang : -- stage: -> resolved ___ Python tracker <http://bugs.python.org/issue28679> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue24339] iso6937 encoding missing

2016-11-13 Thread Xiang Zhang
Changes by Xiang Zhang : -- nosy: +xiang.zhang ___ Python tracker <http://bugs.python.org/issue24339> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue21449] Replace _PyUnicode_CompareWithId with _PyUnicode_CompareWithIdEqual

2016-11-13 Thread Xiang Zhang
Xiang Zhang added the comment: > The name _PyUnicode_CompareWithIdEqual looks too long to me. What about > _PyUnicode_EqualToId? +1. I think this name is more clear. Serhiy's idea on the implementation sounds good. As for _PyUnicode_FROM_ID, I think it's better f

[issue21449] Replace _PyUnicode_CompareWithId with _PyUnicode_CompareWithIdEqual

2016-11-13 Thread Xiang Zhang
Changes by Xiang Zhang : Added file: http://bugs.python.org/file45480/_PyUnicode_EqualToId_v2.patch ___ Python tracker <http://bugs.python.org/issue21449> ___ ___ Pytho

[issue21449] Replace _PyUnicode_CompareWithId with _PyUnicode_CompareWithIdEqual

2016-11-14 Thread Xiang Zhang
Xiang Zhang added the comment: _PyUnicode_FromId could fail due to memoryerror or bad encoded data. They should be treated differently like PyUnicode_READY. Could we treat it like PyDict_GetItem? If memoryerror happens it's highly possible other parts will fai

[issue28563] Arbitrary code execution in gettext.c2py

2016-11-14 Thread Xiang Zhang
Xiang Zhang added the comment: GNU gettext only allows the plural value(n) to be an integer(unsigned long int). Django deliberately converts the value to long in filesizeformat. Any reason not to use int? -- ___ Python tracker <h

[issue28688] Warning -- warnings.filters was modified by test_warnings

2016-11-14 Thread Xiang Zhang
Xiang Zhang added the comment: test___all__ gets the same behaviour. ./python -Werror -m test test___all__ Run tests sequentially 0:00:00 [1/1] test___all__ Warning -- warnings.filters was modified by test___all__ test___all__ failed (env changed) 1 test altered the execution environment

[issue28692] gettext: deprecate selecting plural form by fractional numbers

2016-11-14 Thread Xiang Zhang
Xiang Zhang added the comment: Maybe you have forgotten to remove the debug print in the patch? -- nosy: +xiang.zhang ___ Python tracker <http://bugs.python.org/issue28

[issue28692] gettext: deprecate selecting plural form by fractional numbers

2016-11-15 Thread Xiang Zhang
Xiang Zhang added the comment: I think the stacklevel should be 3. stacklevel = 3: ./python -Walways /tmp/a.py /tmp/a.py:2: DeprecationWarning: Plural value must be an integer, got float c2py('n!=1')(1.1) stacklevel = 4: ./python -Walways /tmp/a.py sys:1: DeprecationWarning: Pl

[issue28692] gettext: deprecate selecting plural form by fractional numbers

2016-11-15 Thread Xiang Zhang
Xiang Zhang added the comment: Ohh, sorry. It should be 4 and I make a mistake. Sorry for the noise. Patch LGTM. -- ___ Python tracker <http://bugs.python.org/issue28

[issue21449] Replace _PyUnicode_CompareWithId with _PyUnicode_CompareWithIdEqual

2016-11-15 Thread Xiang Zhang
Xiang Zhang added the comment: Since currently _PyUnicode_CompareWithId is used to compare a unicode with ascii identifiers for all cases, how about introduce a more specific function like _PyUnicode_EqualToASCIIId for this case? We can preserve _PyUnicode_CompareWithId for more general

[issue28707] add 'directory' option to the http.server module

2016-11-15 Thread Xiang Zhang
Xiang Zhang added the comment: +1 for this idea. I use this command everyday in work and every time must cd to the directory is an annoyance. -- nosy: +xiang.zhang ___ Python tracker <http://bugs.python.org/issue28

[issue28701] Replace PyUnicode_CompareWithASCIIString with _PyUnicode_EqualToASCIIString

2016-11-15 Thread Xiang Zhang
Xiang Zhang added the comment: LGTM. -- ___ Python tracker <http://bugs.python.org/issue28701> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue21449] Replace _PyUnicode_CompareWithId with _PyUnicode_CompareWithIdEqual

2016-11-16 Thread Xiang Zhang
Xiang Zhang added the comment: > _PyUnicode_CompareWithId is a private function. We can remove it if it has > issues. It doesn't. But once there is _PyUnicode_EqualToASCIIId, it's can be rarely used. The new patch implements a version of _PyUnicode_EqualToASCIIId. -

[issue28699] Imap from ThreadPool behaves unexpectedly

2016-11-17 Thread Xiang Zhang
Xiang Zhang added the comment: Hi Davin, could it be fixed like this? diff -r 05a728e1da15 Lib/multiprocessing/pool.py --- a/Lib/multiprocessing/pool.py Wed Nov 16 16:35:53 2016 -0800 +++ b/Lib/multiprocessing/pool.py Thu Nov 17 16:35:38 2016 +0800 @@ -398,7 +398,7

[issue28696] imap from ThreadPool hangs by an exception in a generator function

2016-11-17 Thread Xiang Zhang
Xiang Zhang added the comment: In Py3.6, it raises error: >>> next((pool.imap(str, gen( Traceback (most recent call last): File "/opt/lib/python3.7/multiprocessing/pool.py", line 684, in next item = self._items.popleft() IndexError: pop from an empty deque Dur

[issue28699] Imap from ThreadPool behaves unexpectedly

2016-11-17 Thread Xiang Zhang
Xiang Zhang added the comment: What's more, this case seems non-reentrant. Since there is no task in this case, the job id is always 0 which is not true. This means after the first time, we can not set even the exception. -- ___ Python tr

[issue28699] Imap from ThreadPool behaves unexpectedly

2016-11-17 Thread Xiang Zhang
Xiang Zhang added the comment: Here is a patch which is just a try. I don't quite like the implementation but I can not figure out a better solution. The examples in this one and #28696 seems to work and no test fails currently. -- Added file: http://bugs.python.org/file

[issue28699] Imap from ThreadPool behaves unexpectedly

2016-11-17 Thread Xiang Zhang
Xiang Zhang added the comment: > Your patch looks to be introducing a number of changes to the structure of > the data being passed around between threads and even monitored/indirectly > shared across processes. That's why I say even myself don't like it. To solve an

[issue28398] Return singleton empty string in _PyUnicode_FromASCII

2016-11-18 Thread Xiang Zhang
Xiang Zhang added the comment: > My question is simple: in what circumstances the patch has an effect? My original intention is that there is no need for the caller to check for the empty string. Even there is no use case now, it could be in future. But Serhiy, I am actually very glad to

[issue28750] Replace string with bytes in doc of unicode-escape an raw-unicode-escape

2016-11-20 Thread Xiang Zhang
New submission from Xiang Zhang: The docs of the encoders of unicode-escape and raw-unicode-escape still tell the result of the encoding is Python string object. It should be Python bytes object. -- assignee: docs@python components: Documentation files: unicode-escape-doc.patch

[issue28750] Replace string with bytes in doc of unicode-escape an raw-unicode-escape

2016-11-20 Thread Xiang Zhang
Changes by Xiang Zhang : Added file: http://bugs.python.org/file45559/unicode-escape-doc_v2.patch ___ Python tracker <http://bugs.python.org/issue28750> ___ ___ Python-bug

[issue28750] Replace string with bytes in doc of unicode-escape an raw-unicode-escape

2016-11-20 Thread Xiang Zhang
Xiang Zhang added the comment: > But I think the word "Python" in "Python bytes object" is redundant. It was > needed in "Python string object" to distinguish from "C string" and "Python > Unicode object". Make sense. This "Pyt

[issue28756] robotfileparser always uses default Python user-agent

2016-11-20 Thread Xiang Zhang
Xiang Zhang added the comment: Hi, John. This issue of robotparser has been reported in #15851. I'll close this as duplicate and you can discuss in that thread. -- nosy: +xiang.zhang resolution: -> duplicate status: open -> closed superseder: -> Lib/robotparser.py

[issue15851] Lib/robotparser.py doesn't accept setting a user agent string, instead it uses the default.

2016-11-20 Thread Xiang Zhang
Changes by Xiang Zhang : -- versions: +Python 3.7 -Python 3.5 ___ Python tracker <http://bugs.python.org/issue15851> ___ ___ Python-bugs-list mailing list Unsub

[issue28760] Cleanup PyUnicode_AsUnicodeEscapeString

2016-11-21 Thread Xiang Zhang
New submission from Xiang Zhang: PyUnicode_AsUnicodeEscapeString now still has some old comments and codes about the original "quotes" parameter of unicodeescape_string. Current implementation could get rid of them. -- files: PyUnicode_AsUnicodeEscapeString.patch keywo

[issue28760] Cleanup PyUnicode_AsUnicodeEscapeString

2016-11-21 Thread Xiang Zhang
Xiang Zhang added the comment: Thanks for your work, Serhiy. ;-) -- ___ Python tracker <http://bugs.python.org/issue28760> ___ ___ Python-bugs-list mailin

[issue27414] http.server.BaseHTTPRequestHandler inconsistence with Content-Length value

2016-11-22 Thread Xiang Zhang
Xiang Zhang added the comment: v2 applies the suggestions. -- priority: low -> normal versions: +Python 3.7 Added file: http://bugs.python.org/file45597/issue27414_v2.patch ___ Python tracker <http://bugs.python.org/issu

[issue28766] Remove the semicolon in source code

2016-11-22 Thread Xiang Zhang
Changes by Xiang Zhang : -- stage: -> resolved ___ Python tracker <http://bugs.python.org/issue28766> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue28774] Better start and end position for unicodeerror in unicode_encode_ucs1

2016-11-22 Thread Xiang Zhang
New submission from Xiang Zhang: unicode_encode_ucs1 now recognizes as many characters as it can one time instead of one character a time. But the unicodeerror positions still only count 1(the second time). A similar problem reported in #28561. -- components: Interpreter Core files

<    13   14   15   16   17   18