[issue27299] urllib does not splitport while putrequest realhost to HTTP headers

2016-06-12 Thread Xiang Zhang
Xiang Zhang added the comment: It's server side behaviour. Asking here may not get results. I think it's normal for the server to return error if it thinks the header is invalid. -- ___ Python tracker <http://bugs.python.o

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-14 Thread Xiang Zhang
Xiang Zhang added the comment: Hello Martin. I've finished a patch to add 64bit support to zlib. I think it solves the 9 problems you mentioned and let the input and output both be larger than UINT_MAX. Hope you are willing to review and we can move this forward. :) -- key

[issue27177] re match.group should support __index__

2016-06-15 Thread Xiang Zhang
Xiang Zhang added the comment: Attach a patch to add this feature to Py3.6. -- nosy: +xiang.zhang Added file: http://bugs.python.org/file43396/issue27177.patch ___ Python tracker <http://bugs.python.org/issue27

[issue7769] SimpleXMLRPCServer.SimpleXMLRPCServer.register_function as decorator

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

[issue7769] SimpleXMLRPCServer.SimpleXMLRPCServer.register_function as decorator

2016-06-15 Thread Xiang Zhang
Xiang Zhang added the comment: Hi, I've written a patch to accomplish this in Py3.6. This patch is much cleaner but has one drawback, when used as decorator factory, you have to specify name as a keyword argument. But considering the codes that have to been imported to check argumen

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-16 Thread Xiang Zhang
Xiang Zhang added the comment: I'm willing to and thanks for your work too :) I have replied to your comments and adjusted my patch accordingly. But there are still several I am confused or want to negotiate more. I now upload the adjusted patch. -- Added file:

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-16 Thread Xiang Zhang
Xiang Zhang added the comment: Sorry, I suddenly find that I've misunderstood one of your comments. I changed according then. Please use the new version. -- Added file: http://bugs.python.org/file43408/64bit_support_for_zlib_v3.patch ___ P

[issue26985] Information about CodeType in inspect documentation is outdated

2016-06-16 Thread Xiang Zhang
Xiang Zhang added the comment: Hmm, when I am going to delete the list in the docstring, I find other functions get lists too in inspect.py. So maybe we should open another issue to clean them after first merging this thread? -- ___ Python tracker

[issue27333] validate_step in rangeobject.c, incorrect code logic but right result

2016-06-16 Thread Xiang Zhang
New submission from Xiang Zhang: Here is a drawback in validate_step of rangeobject. PyNumber_AsSsize_t returns clipped value and won't set an exception when the argument *exc* is set NULL. So if step overflows, istep is always PY_SSIZE_MAX or PY_SSIZE_MIN. But the following code is to

[issue27333] validate_step in rangeobject.c, incorrect code logic but right result

2016-06-16 Thread Xiang Zhang
Changes by Xiang Zhang : -- components: +Interpreter Core type: -> behavior versions: +Python 2.7, Python 3.5, Python 3.6 ___ Python tracker <http://bugs.python.org/issu

[issue27342] Clean up some Py_XDECREFs in rangeobject.c and bltinmodule.c

2016-06-17 Thread Xiang Zhang
New submission from Xiang Zhang: Some Py_XDECREFs in rangeobject.c and bltinmodule.c are not necessary. Py_DECREF is enough. Clean up them. -- files: cleanup_some_xdecrefs.patch keywords: patch messages: 268711 nosy: xiang.zhang priority: normal severity: normal status: open title

[issue27333] validate_step in rangeobject.c, incorrect code logic but right result

2016-06-17 Thread Xiang Zhang
Xiang Zhang added the comment: This looks fine. But maybe code like this looks more clear: if (step && _PyLong_Sign(step) == 0) { PyErr_SetString(PyExc_ValueError, "range() arg 3 must not be zero"); Py_CLEAR(step); } I think assert(PyLong_Check(

[issue27342] Clean up some Py_XDECREFs in rangeobject.c and bltinmodule.c

2016-06-17 Thread Xiang Zhang
Xiang Zhang added the comment: Thanks for review. Eliminate the wrongs ones. -- Added file: http://bugs.python.org/file43440/cleanup_some_xdecrefs_v2.patch ___ Python tracker <http://bugs.python.org/issue27

[issue7769] SimpleXMLRPCServer.SimpleXMLRPCServer.register_function as decorator

2016-06-17 Thread Xiang Zhang
Changes by Xiang Zhang : -- nosy: +loewis, serhiy.storchaka ___ Python tracker <http://bugs.python.org/issue7769> ___ ___ Python-bugs-list mailing list Unsub

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-18 Thread Xiang Zhang
Xiang Zhang added the comment: Upload the new patch to fix bugs and make improvements. I'll add tests later. -- Added file: http://bugs.python.org/file43450/64bit_support_for_zlib_v4.patch ___ Python tracker <http://bugs.python.org/is

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-18 Thread Xiang Zhang
Changes by Xiang Zhang : Added file: http://bugs.python.org/file43459/64bit_support_for_zlib_v4.patch ___ Python tracker <http://bugs.python.org/issue27130> ___ ___ Pytho

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-18 Thread Xiang Zhang
Changes by Xiang Zhang : Removed file: http://bugs.python.org/file43450/64bit_support_for_zlib_v4.patch ___ Python tracker <http://bugs.python.org/issue27130> ___ ___

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-18 Thread Xiang Zhang
Xiang Zhang added the comment: Attach patch to restore argument parsing support for __int__. -- Added file: http://bugs.python.org/file43460/64bit_support_for_zlib_v5.patch ___ Python tracker <http://bugs.python.org/issue27

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-18 Thread Xiang Zhang
Changes by Xiang Zhang : Removed file: http://bugs.python.org/file43460/64bit_support_for_zlib_v5.patch ___ Python tracker <http://bugs.python.org/issue27130> ___ ___

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-18 Thread Xiang Zhang
Changes by Xiang Zhang : Added file: http://bugs.python.org/file43461/64bit_support_for_zlib_v5.patch ___ Python tracker <http://bugs.python.org/issue27130> ___ ___ Pytho

[issue27351] Unexpected ConfigParser.read() behavior when passed fileobject

2016-06-18 Thread Xiang Zhang
Xiang Zhang added the comment: The doc tells ConfigParser.read accepts a filename or a list of filenames. Why do you pass it fileobject? If you want to use fileobject, why not read_file? -- nosy: +lukasz.langa, xiang.zhang ___ Python tracker <h

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-19 Thread Xiang Zhang
Xiang Zhang added the comment: Upload the near-final patch. This one adds large buffer tests on 64bit platforms. I have tested them on a server with enough memory. I don't add the @support.requires_resource('cpu') since large memory tests are born to be slow. And actually wh

[issue26537] ConfigParser has optionxform, but not sectionxform

2016-06-23 Thread Xiang Zhang
Xiang Zhang added the comment: ping -- ___ Python tracker <http://bugs.python.org/issue26537> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue27381] Typo in zipfile documentation

2016-06-24 Thread Xiang Zhang
New submission from Xiang Zhang: There is a redundant ')' in zipfile doc. Remove it. -- assignee: docs@python components: Documentation files: zipfile_doc.patch keywords: patch messages: 269166 nosy: docs@python, xiang.zhang priority: normal severity: normal status: open titl

[issue22079] Ensure in PyType_Ready() that base class of static type is static

2016-06-24 Thread Xiang Zhang
Xiang Zhang added the comment: I think we can start from index 1 instead of 0. -- nosy: +xiang.zhang ___ Python tracker <http://bugs.python.org/issue22

[issue22079] Ensure in PyType_Ready() that base class of static type is static

2016-06-25 Thread Xiang Zhang
Xiang Zhang added the comment: In the mro list I think the first is always the type itself which has already been checked to be a statically allocated type if we can touch the loop. Starting from 0 checks it twice and it's not a base either. BTW, I don't receive an email from t

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-25 Thread Xiang Zhang
Xiang Zhang added the comment: Add the newest version applying Martin's comments. -- Added file: http://bugs.python.org/file43538/64bit_support_for_zlib_v7.patch ___ Python tracker <http://bugs.python.org/is

[issue22079] Ensure in PyType_Ready() that base class of static type is static

2016-06-25 Thread Xiang Zhang
Xiang Zhang added the comment: Of course, I know it. But doesn't the local variable `bases` refer to mro[1]? [1] https://hg.python.org/cpython/file/tip/Objects/typeobject.c#l4900 -- ___ Python tracker <http://bugs.python.org/is

[issue22079] Ensure in PyType_Ready() that base class of static type is static

2016-06-25 Thread Xiang Zhang
Xiang Zhang added the comment: I thought that too at first. But if we use __bases__, can we still guarantee that 'all bases of statically allocated type should be statically allocated'? How about its grand bases? Is it possible that a statically allocated type inherit a dynamic typ

[issue22079] Ensure in PyType_Ready() that base class of static type is static

2016-06-26 Thread Xiang Zhang
Xiang Zhang added the comment: Oh yes. The mro list can be customized so we can not even guarantee the type appears at index 0 and object at index n-1. It seems we should still keep what it is now, iterating the whole mro list. Sorry that my previous comments seem to be noise. But maybe we

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-27 Thread Xiang Zhang
Xiang Zhang added the comment: This is the v8 patch. It does two things: [1] Apply Martin's comment about decompressobj.decompress so when user passes in PY_SSIZE_T_MAX and there is enough memory, no error will be raised. [2] Now decompressobj.flush can still work ev

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-27 Thread Xiang Zhang
Changes by Xiang Zhang : Added file: http://bugs.python.org/file43563/64bit_support_for_zlib_v8.patch ___ Python tracker <http://bugs.python.org/issue27130> ___ ___ Pytho

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-27 Thread Xiang Zhang
Changes by Xiang Zhang : Removed file: http://bugs.python.org/file43561/64bit_support_for_zlib_v8.patch ___ Python tracker <http://bugs.python.org/issue27130> ___ ___

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-27 Thread Xiang Zhang
Changes by Xiang Zhang : Removed file: http://bugs.python.org/file43563/64bit_support_for_zlib_v8.patch ___ Python tracker <http://bugs.python.org/issue27130> ___ ___

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-27 Thread Xiang Zhang
Xiang Zhang added the comment: Make v8 patch consistent with the latest changeset. -- Added file: http://bugs.python.org/file43564/64bit_support_for_zlib_v8.patch ___ Python tracker <http://bugs.python.org/issue27

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-27 Thread Xiang Zhang
Changes by Xiang Zhang : Added file: http://bugs.python.org/file43565/64bit_support_for_zlib_v8.patch ___ Python tracker <http://bugs.python.org/issue27130> ___ ___ Pytho

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-06-27 Thread Xiang Zhang
Changes by Xiang Zhang : Removed file: http://bugs.python.org/file43564/64bit_support_for_zlib_v8.patch ___ Python tracker <http://bugs.python.org/issue27130> ___ ___

[issue27401] Wrong FTP links in 5.3.2 installer

2016-06-27 Thread Xiang Zhang
Changes by Xiang Zhang : -- nosy: +larry ___ Python tracker <http://bugs.python.org/issue27401> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue27411] Possible different behaviour of explicit and implicit __dict__ accessing when involving builtin types' __dict__ descriptors

2016-06-29 Thread Xiang Zhang
New submission from Xiang Zhang: Usually when we access an object's __dict__, it will finally reach subtype_dict[0]. When involving builtin base, it may delegates to the base's __dict__ descriptor. In such a case, it is possible for the __dict__ descriptor to initialize the dict

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

2016-06-29 Thread Xiang Zhang
Changes by Xiang Zhang : -- nosy: +ezio.melotti, pitrou, rhettinger ___ Python tracker <http://bugs.python.org/issue27414> ___ ___ Python-bugs-list mailin

[issue26664] find a bug in activate.fish of venv of cpython3.6

2016-06-30 Thread Xiang Zhang
Xiang Zhang added the comment: I get the same feeling. Add Larry. -- nosy: +larry ___ Python tracker <http://bugs.python.org/issue26664> ___ ___ Python-bugs-list m

[issue26664] Misuse of $ in activate.fish of venv

2016-06-30 Thread Xiang Zhang
Xiang Zhang added the comment: Since the bug is fixed, we can also close issue26348. -- ___ Python tracker <http://bugs.python.org/issue26664> ___ ___ Python-bug

[issue27429] xml.sax.saxutils.escape doesn't escape multiple characters safely

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

[issue27436] Strange code in selectors.KqueueSelector

2016-07-01 Thread Xiang Zhang
Xiang Zhang added the comment: EVENT_* and KQ_FILTER_* are two different sets of constants. EVENT_* represent event types of the abstract event and KQ_FILTER_* represent the kevent filter type. EVENT_* can be combined while kevent.filter can only get one type. -- nosy: +xiang.zhang

[issue27436] Strange code in selectors.KqueueSelector

2016-07-01 Thread Xiang Zhang
Xiang Zhang added the comment: What I am saying is that EVENT_* (1, 2) are bit_masks while KQ_FILTER_* not (-1, -2, -3, -4). So you should use |= with EVENT_* and == with KQ_FILTER_*. It seems not a bug. :) -- ___ Python tracker <h

[issue27436] Strange code in selectors.KqueueSelector

2016-07-01 Thread Xiang Zhang
Xiang Zhang added the comment: But EVENT_* are. If you use =, events can only be either EVENT_READ or EVENT_WRITE, not EVENT_READ & EVENT_WRITE. EVENT_* != KQ_FILTER_*. -- ___ Python tracker <http://bugs.python.org/iss

[issue27436] Strange code in selectors.KqueueSelector

2016-07-01 Thread Xiang Zhang
Xiang Zhang added the comment: Oh, sorry. My focus seem to be on the wrong place. I thought David is arguing something about the constants are bitmasks or not. It's my fault. But actually the current code looks very clearly and I can tell from it that EVENT_* are bitmasks and KQ_FILTER_

[issue27429] xml.sax.saxutils.escape doesn't escape multiple characters safely

2016-07-03 Thread Xiang Zhang
Xiang Zhang added the comment: I think this a bug. There should be no override when escape or unescape. Upload a patch to fix this. -- keywords: +patch nosy: +martin.panter, serhiy.storchaka Added file: http://bugs.python.org/file43616/issue27429.patch

[issue27429] xml.sax.saxutils.escape doesn't escape multiple characters safely

2016-07-03 Thread Xiang Zhang
Xiang Zhang added the comment: I thought of that too. But the doc doesn't tell you that you can not put any characters in the entities, so I think we should make the implementation right when some unexpected characters are passed in. If you don't like the implementation to be change

[issue27429] xml.sax.saxutils.escape doesn't escape multiple characters safely

2016-07-03 Thread Xiang Zhang
Xiang Zhang added the comment: Put a not in escape's doc. -- Added file: http://bugs.python.org/file43617/sax_escape_doc.patch ___ Python tracker <http://bugs.python.org/is

[issue27457] shlex.quote incorrectly quotes ampersants, pipes

2016-07-05 Thread Xiang Zhang
Xiang Zhang added the comment: Doesn't this the expected behaviour of shlex.quote, return a shell-escaped version of the string s? If && is not quoted, how about "pwd && rm -rf ~"? I think in your case there is no need to use shlex.quote.

[issue7769] SimpleXMLRPCServer.SimpleXMLRPCServer.register_function as decorator

2016-07-06 Thread Xiang Zhang
Xiang Zhang added the comment: ping -- ___ Python tracker <http://bugs.python.org/issue7769> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue27248] Possible refleaks in PyType_Ready in error condition

2016-07-06 Thread Xiang Zhang
Xiang Zhang added the comment: ping -- ___ Python tracker <http://bugs.python.org/issue27248> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue26915] Test identity first in membership operation of ItemsView, ValuesView and Sequence in collections.abc

2016-07-06 Thread Xiang Zhang
Xiang Zhang added the comment: ping -- ___ Python tracker <http://bugs.python.org/issue26915> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue27460] Change bytes exception when overflow

2016-07-06 Thread Xiang Zhang
New submission from Xiang Zhang: I suggest change `bytes` exception message when an iterable containing overflow integers. Right now, bytes([sys.maxsize+1]) emits ValueError: cannot fit 'int' into an index-sized integer "ValueError: cannot fit 'int' into an index

[issue27460] Change bytes exception when overflow

2016-07-06 Thread Xiang Zhang
Changes by Xiang Zhang : -- type: -> enhancement versions: +Python 3.6 ___ Python tracker <http://bugs.python.org/issue27460> ___ ___ Python-bugs-list mai

[issue27460] Change bytes exception when overflow

2016-07-06 Thread Xiang Zhang
Changes by Xiang Zhang : Added file: http://bugs.python.org/file43643/bytes_exception_msg.patch ___ Python tracker <http://bugs.python.org/issue27460> ___ ___ Python-bug

[issue27460] Change bytes exception when overflow

2016-07-06 Thread Xiang Zhang
Changes by Xiang Zhang : Removed file: http://bugs.python.org/file43637/bytes_exception_msg.patch ___ Python tracker <http://bugs.python.org/issue27460> ___ ___ Python-bug

[issue27460] Change bytes exception when overflow

2016-07-06 Thread Xiang Zhang
Xiang Zhang added the comment: The constructor has been well tested in https://hg.python.org/cpython/file/tip/Lib/test/test_bytes.py#l111. It looks like that the original author only wants to guarantee the exception type but not message. So I didn't add a assertRaisesRegex

[issue7769] SimpleXMLRPCServer.SimpleXMLRPCServer.register_function as decorator

2016-07-07 Thread Xiang Zhang
Xiang Zhang added the comment: >From the old comments from Brian it seems he's willing to accept such a >feature. But unfortunately Brian seems not interested in this now. IMHO, this >is good feature especially to people familiar with Bottle and Flask. Writing >in a decorat

[issue27467] distutils.config API different between <=3.5.1 and 3.5.2

2016-07-08 Thread Xiang Zhang
Xiang Zhang added the comment: I think it's intentional. You can see issue20120. -- nosy: +xiang.zhang ___ Python tracker <http://bugs.python.org/is

[issue27467] distutils.config API different between <=3.5.1 and 3.5.2

2016-07-08 Thread Xiang Zhang
Xiang Zhang added the comment: Berker, what doc needs to be changed? Although RawConfigParser is legacy but that does not mean it's deprecated, right? We can still use it although the doc suggests us use ConfigParser. -- ___ Python tracker

[issue27473] bytes_concat seems to check overflow using undefined behaviour

2016-07-09 Thread Xiang Zhang
Changes by Xiang Zhang : -- type: -> behavior versions: +Python 3.6 ___ Python tracker <http://bugs.python.org/issue27473> ___ ___ Python-bugs-list mai

[issue27473] bytes_concat seems to check overflow using undefined behaviour

2016-07-09 Thread Xiang Zhang
New submission from Xiang Zhang: bytes_concat uses following code to check overflow: size = va.len + vb.len; if (size < 0): { PyErr_NoMemory(); goto done; } This is wrong since signed ints overflow is undefined bahaviour. But one point is that Python's Makefile defines -fwr

[issue27474] Unify exception in _Py_bytes_contains for integers

2016-07-09 Thread Xiang Zhang
New submission from Xiang Zhang: Now, `sys.maxsize+1 in b'foo'` raises "TypeError: 'int' does not support the buffer interface" which seems weird. In such case, I don't think there is any difference between sys.maxsize+1 and 256. So I suggest make it emits th

[issue27473] bytes_concat seems to check overflow using undefined behaviour

2016-07-09 Thread Xiang Zhang
Xiang Zhang added the comment: Attach a patch to fix this. -- keywords: +patch Added file: http://bugs.python.org/file43671/bytes_concat_overflow_check.patch ___ Python tracker <http://bugs.python.org/issue27

[issue27473] bytes_concat seems to check overflow using undefined behaviour

2016-07-10 Thread Xiang Zhang
Xiang Zhang added the comment: Yes, the current code is valid with -fwrapv. But I am not sure if every compiler supports this feature. So maybe we can't totally rely on it. And in issue1621, some efforts seem to have worked to factor thes

[issue27473] bytes_concat seems to check overflow using undefined behaviour

2016-07-10 Thread Xiang Zhang
Xiang Zhang added the comment: Of course. I forgot to check bytearray. :( The new patch now also includes bytearray. -- Added file: http://bugs.python.org/file43675/bytes_concat_overflow_check_v2.patch ___ Python tracker <http://bugs.python.

[issue27473] bytes_concat seems to check overflow using undefined behaviour

2016-07-10 Thread Xiang Zhang
Xiang Zhang added the comment: Sorry. v3 now includes iconcat. -- Added file: http://bugs.python.org/file43676/bytes_concat_overflow_check_v3.patch ___ Python tracker <http://bugs.python.org/issue27

[issue27473] bytes_concat seems to check overflow using undefined behaviour

2016-07-10 Thread Xiang Zhang
Xiang Zhang added the comment: Left a comment. -- ___ Python tracker <http://bugs.python.org/issue27473> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue26867] test_ssl test_options fails on ubuntu 16.04

2016-07-10 Thread Xiang Zhang
Xiang Zhang added the comment: Does this need to be backport to py2.7? It suffers from the same problem. -- ___ Python tracker <http://bugs.python.org/issue26

[issue27481] Replace TypeError with ValueError in doc regarding "embedded NUL character"

2016-07-11 Thread Xiang Zhang
New submission from Xiang Zhang: Errors regarding "embedded NUL character" were changed from TypeError to ValueError, in r92365, issue22215, but the doc doesn't get updated. Add a patch to apply the change in doc. -- assignee: docs@python components: Docu

[issue27481] Replace TypeError with ValueError in doc regarding "embedded NUL character"

2016-07-11 Thread Xiang Zhang
Xiang Zhang added the comment: Just for a note, there has already been an issue26401 fixing the function.rst. Upload a new patch adding versionchanged tag. -- Added file: http://bugs.python.org/file43686/null_characters_doc_v2.patch ___ Python

[issue27481] Replace TypeError with ValueError in doc regarding "embedded NUL character"

2016-07-11 Thread Xiang Zhang
Xiang Zhang added the comment: Yes. I noticed the change but didn't change it. Now add it. -- Added file: http://bugs.python.org/file43689/null_characters_doc_v3.patch ___ Python tracker <http://bugs.python.org/is

[issue27481] Replace TypeError with ValueError in doc regarding "embedded NUL character"

2016-07-11 Thread Xiang Zhang
Xiang Zhang added the comment: Sorry, I didn't notice the difference. -- Added file: http://bugs.python.org/file43690/null_characters_doc_v4.patch ___ Python tracker <http://bugs.python.org/is

[issue27492] Enhance bytearray_repr with bytes_repr's logic

2016-07-12 Thread Xiang Zhang
New submission from Xiang Zhang: Right now bytearray_repr's implementation mimics old string_repr, but it has a drawback: It arbitrarily checks overflow using four times the bytearray object's length, but the representation length of the value can range from 1 to 4. I think

[issue27492] Enhance bytearray_repr with bytes_repr's logic

2016-07-12 Thread Xiang Zhang
Xiang Zhang added the comment: I considered that too. But I was not sure what code could go into bytes_methods.c then, Python level methods, all common parts or only tp->methods? I'll try to factor the common part out later. -- ___ Python

[issue27492] Enhance bytearray_repr with bytes_repr's logic

2016-07-12 Thread Xiang Zhang
Xiang Zhang added the comment: Hi, Serhiy. I've tried one version factoring the common parts out. I make them one function but it seems not very elegant. I also think about passing the object and use it to get the type and then determine how to get the string, what the pre/postfix are

[issue27506] bytes/bytearray delete acts as keyword argument

2016-07-13 Thread Xiang Zhang
New submission from Xiang Zhang: Write a patch to make bytes/bytearray.translate's delete argument support acting as keyword arguments. This won't break any backwards compatibility and make the method more flexible to use. Besides, in the C code level, it stops using argument clini

[issue27506] make bytes/bytearray deletechars a keyword argument named delete

2016-07-13 Thread Xiang Zhang
Xiang Zhang added the comment: Hmm, David, that may be not quite right. Users only reading the doc never know it's deletechars not delete. The doc is always delete, though conflicting with __doc__. >>> print(bytes.translate.__doc__) B.translate(table[, deletechars]) -

[issue27506] make bytes/bytearray delete a keyword argument

2016-07-13 Thread Xiang Zhang
Xiang Zhang added the comment: Please review the new version. It makes two changes comparing with the last one. 1. It exposes Python parameter as "delete" (which the document always uses so I think it's the API) while still use "deletechars" (which I prefer as a C var

[issue27507] bytearray.extend lacks overflow check when increasing buffer

2016-07-13 Thread Xiang Zhang
New submission from Xiang Zhang: As the title, bytearray.extend simply use `buf_size = len + (len >> 1) + 1;` to determine next *buf_size* when increasing buffer. But this can overflow in theory. So I suggest adding overflow check. -- components: Interpreter Core

[issue27507] bytearray.extend lacks overflow check when increasing buffer

2016-07-13 Thread Xiang Zhang
Xiang Zhang added the comment: Ohh, sorry for the disturb. I made a mistake. This is not needed and now close it. -- resolution: -> not a bug status: open -> closed ___ Python tracker <http://bugs.python.org/i

[issue27507] bytearray.extend lacks overflow check when increasing buffer

2016-07-13 Thread Xiang Zhang
Xiang Zhang added the comment: Sorry, after checking again, this is still needed but maybe `if (len == PY_SSIZE_T_MAX)` part is not necessary since the iterable's length should not be larger than PY_SSIZE_T_MAX. But keep it to avoid theoretically bug is not a bad idea. -- s

[issue27506] make bytes/bytearray delete a keyword argument

2016-07-13 Thread Xiang Zhang
Xiang Zhang added the comment: Thanks for your comment Martin. I'll apply them later when we reach agreement on functions. I have already used object = NULL, the C default is not necessary here, and it works as you like I think. In patch version 1, b'abc'.translate(None

[issue27507] bytearray.extend lacks overflow check when increasing buffer

2016-07-13 Thread Xiang Zhang
Xiang Zhang added the comment: Nice to see the real example. I don't think of that. -- ___ Python tracker <http://bugs.python.org/issue27507> ___ ___ Pytho

[issue27511] Add PathLike objects support to BZ2File

2016-07-14 Thread Xiang Zhang
New submission from Xiang Zhang: Attach a patch to add PathLike objects support to BZ2File. -- files: add_PathLike_objects_support_to_BZ2File.patch keywords: patch messages: 270385 nosy: brett.cannon, ethan.furman, xiang.zhang priority: normal severity: normal status: open title: Add

[issue27511] Add PathLike objects support to BZ2File

2016-07-14 Thread Xiang Zhang
Changes by Xiang Zhang : -- components: +Library (Lib) type: -> enhancement versions: +Python 3.6 ___ Python tracker <http://bugs.python.org/issue27511> ___ _

[issue27512] os.fspath is certain to crash when exception raised in __fspath__

2016-07-14 Thread Xiang Zhang
New submission from Xiang Zhang: When any exception is raised inside __fspath__, operations involving it like os.fspath, open are certain to crash. >>> import os >>> class Test: ... def __fspath__(self): ... raise RuntimeError ... >>> os.fspath(Test(

[issue27512] os.fspath is certain to crash when exception raised in __fspath__

2016-07-14 Thread Xiang Zhang
Xiang Zhang added the comment: BTW, the code is also listed in PEP519. So maybe that also needs to be fixed. -- ___ Python tracker <http://bugs.python.org/issue27

[issue27512] os.fspath is certain to crash when exception raised in __fspath__

2016-07-14 Thread Xiang Zhang
Xiang Zhang added the comment: Ahh, adding tests is easy. But this seems to be just a careless omission, so maybe tests is not a must. -- ___ Python tracker <http://bugs.python.org/issue27

[issue27507] bytearray.extend lacks overflow check when increasing buffer

2016-07-14 Thread Xiang Zhang
Xiang Zhang added the comment: So would you like to merge it like this or Martin's alternative way? But honestly speaking I don't get Martin's point, "without trying to allocate Py_SSIZE_T_MAX first", where is this place? -- _

[issue27512] os.fspath is certain to crash when exception raised in __fspath__

2016-07-14 Thread Xiang Zhang
Xiang Zhang added the comment: I think such omissions are hard to predict and you won't know where is the omission until you encounter it. So if you don't know, how do you know what to put in the tests? And if it is encountered and fixed, such errors should not ha

[issue27507] bytearray.extend lacks overflow check when increasing buffer

2016-07-14 Thread Xiang Zhang
Xiang Zhang added the comment: Thanks for the analysis Antti. I don't think if (len == PY_SSIZE_T_MAX) can be moved inside the *other* if. Their handlings are different. if (len == PY_SSIZE_T_MAX) is True, it should exit immediately. But in the *other* if, you can still have a try to all

[issue27512] os.fspath is certain to crash when exception raised in __fspath__

2016-07-14 Thread Xiang Zhang
Xiang Zhang added the comment: The test requests for the whole fspath are reasonable. I just don't want to add tests for these two lines. 1) and 3) have already been tested. I add 2) and reorganize the existing tests a little. -- Added file: http://bugs.python.org/file

[issue27512] os.fspath is certain to crash when exception raised in __fspath__

2016-07-14 Thread Xiang Zhang
Xiang Zhang added the comment: I have to explain for myself. First, I know tests *are* important. This is not the first time uploading patches here. I don't want to add tests for this case is because such codes: call something and test for failure appears all the places in the code base.

[issue27512] os.fspath is certain to crash when exception raised in __fspath__

2016-07-14 Thread Xiang Zhang
Xiang Zhang added the comment: Thanks Brett, also others. Restore the moving around. -- Added file: http://bugs.python.org/file43723/fix_fspath_crash_v3.patch ___ Python tracker <http://bugs.python.org/issue27

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-07-14 Thread Xiang Zhang
Xiang Zhang added the comment: ping -- ___ Python tracker <http://bugs.python.org/issue27130> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue27130] zlib: OverflowError while trying to compress 2^32 bytes or more

2016-07-16 Thread Xiang Zhang
Xiang Zhang added the comment: Upload the v9 version. It applies your last comment and catch up with the hg tip. -- Added file: http://bugs.python.org/file43750/64bit_support_for_zlib_v9.patch ___ Python tracker <http://bugs.python.org/issue27

[issue27507] bytearray.extend lacks overflow check when increasing buffer

2016-07-16 Thread Xiang Zhang
Xiang Zhang added the comment: I can't totally agree the point. The code means every time we increase the buffer by half the current length. So when the length arrives 2/3 * PY_SSIZE_T_MAX it's going to overflow. There is a 1/3 * PY_SSIZE_T_MAX gap between the theoretical upper limi

<    5   6   7   8   9   10   11   12   13   14   >