[issue12381] bytearray methods count, find, index don't support None as in slice notation
Changes by Xuanji Li xua...@gmail.com: -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12381 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12170] Bytes.index() and bytes.count() should accept byte ints
Changes by Xuanji Li xua...@gmail.com: -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12170 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10376] ZipFile unzip is unbuffered
Changes by Xuanji Li xua...@gmail.com: -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10376 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9938] Documentation for argparse interactive use
Xuanji Li xua...@gmail.com added the comment: Updated previous patch with test cases and renamed exit_on_argument_error flag to exit_on_error. -- Added file: http://bugs.python.org/file22172/issue9938_with_test.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9938 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9938] Documentation for argparse interactive use
Xuanji Li xua...@gmail.com added the comment: I don't think it's best to create a new subclass to throw an ArgumentParserExit exception; if I read the stack trace I'd see that an ArgumentError was thrown, then caught, then an ArgumentParserExit was thrown, which IMHO is confusing. In the current design, parse_known_errors catches an ArgumentError and then exits. I propose that the user be optionally allowed to turn off the handling of ArgumentError and to handle it himself instead through an exit_on_argument_error flag. Attached patch does this. Also I think this issue falls under component 'Lib' too. -- components: +Library (Lib) keywords: +patch Added file: http://bugs.python.org/file21793/issue9938.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9938 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3451] Asymptotically faster divmod and str(long)
Changes by Xuanji Li xua...@gmail.com: -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3451 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11588] Add necessarily inclusive groups to argparse
Changes by Xuanji Li xua...@gmail.com: -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11588 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11874] argparse assertion failure with brackets in metavars
Changes by Xuanji Li xua...@gmail.com: -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11874 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9723] Add shlex.quote
Changes by Xuanji Li xua...@gmail.com: -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9723 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11837] smtplib._quote_periods triggers spurious type error in re.sub
Changes by Xuanji Li xua...@gmail.com: -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11837 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5115] Extend subprocess.kill to be able to kill process groups
Changes by Xuanji Li xua...@gmail.com: -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11872] cPickle gives strange error for large objects.
Changes by Xuanji Li xua...@gmail.com: -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11872 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5723] Incomplete json tests
Changes by Xuanji Li xua...@gmail.com: -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5723 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10694] zipfile.py end of central directory detection not robust
Xuanji Li xua...@gmail.com added the comment: Hi, can someone look at the patch? There doesn't seem to be any objections to it and it'll solve a long-standing issue. Thanks! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10694 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11127] sockets should not be pickleable
Xuanji Li xua...@gmail.com added the comment: the correct way is to provide a __getstate__ method for socket right? I have implemented that in the attached patch. -- keywords: +patch nosy: +xuanji Added file: http://bugs.python.org/file20803/issue11127.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11127 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5231] Change format of a memoryview
Changes by Xuanji Li xua...@gmail.com: -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5231 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5231] Change format of a memoryview
Xuanji Li xua...@gmail.com added the comment: Is this issue from 2 years ago still open? I checked the docs and it seems to be. If it is, I would like to work on a patch and submit it soon. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5231 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10694] zipfile.py end of central directory detection not robust
Xuanji Li xua...@gmail.com added the comment: I've attached a patch copying rep's patch from issue 10298, as i think it is cleaner (but it seems to do the same thing as kevin's patch) together with 2 test cases. David Murray: I'm not really sure what you mean by test comments with trailing data; as I understand, the way to fix the problem is simply to remove the excessively strict check that the length the zip file claims to have is equal to the actual amount of comments found by truncating comments to the claimed size; if that's the case my (new) test should be enough to exercise that logic. Please correct me if I misunderstand. -- Added file: http://bugs.python.org/file20723/reps_patch_and_two_tests.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10694 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11160] ZipFile.comment expects bytes
New submission from Xuanji Li xua...@gmail.com: The documentation for zipfile describes ZipFile.comment as The comment text associated with the ZIP file. From reading this I expect that setting it to a string is ok; however ZipFile.comment must actually be set to bytes (or a bytes-like object, I am not very sure). This may also unexpectedly affect old code because I saw one patch on the bug tracker that was written just last year that set ZipFile.comment to a string. IMO there are 2 ways to fix: 1) Change docs to mention that ZipFile.comment only accepts bytes 2) Patch zipfile.py to accept string and try to convert, throwing an error if the conversion fails -- assignee: docs@python components: Documentation, Library (Lib) messages: 128217 nosy: docs@python, haypo, xuanji priority: normal severity: normal status: open title: ZipFile.comment expects bytes versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11160 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: Yes, I think we should close it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10694] zipfile.py end of central directory detection not robust
Xuanji Li xua...@gmail.com added the comment: Ok, new patch that creates a zipfile (actually I used TESTFN2, all the other tests seem to also use it) -- Added file: http://bugs.python.org/file20200/Issue10694_2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10694 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10044] small int optimization
Xuanji Li xua...@gmail.com added the comment: fwiw I've always found this helpful for undefined behavior: http://blog.regehr.org/archives/213 and, just as it says x+1 x will be optimized to a nop, by the same logic v = array[0] v array[array_len] will also be optimized to a nop. -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10044 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10694] zipfile.py end of central directory detection not robust
Xuanji Li xua...@gmail.com added the comment: Hi KevinH, sorry if I gave the wrong impression that you must submit a patch before anyone will look at the bug. I thought you wanted to provide a patch for this. If you only want to report a bug that is ok, thanks for that. I have confirmed your bug on the py3k branch. Attached is a patch that adds a test case to test_zipfile.py (as requested by others) and ports Kevin's patch to py3k. I have confirmed that his patch works: without it the test fails, and with it the test passes. Note: You have to create a file README.zip in the Lib/test directory, because svn diff cannot display added files. -- Added file: http://bugs.python.org/file20127/Issue10694.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10694 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10694] zipfile.py end of central directory detection not robust
Xuanji Li xua...@gmail.com added the comment: Sorry, forgot to add: README.zip should have a \r\n at the end. Actually I just zipped up README, ran echo \r\n README.zip and put it in Lib/test. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10694 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: Hello, sorry for commenting on a closed issue... but I think the documentation change is incorrect. In urllib.request.rst, it says data is a string. However as seen in the changes to test_urllib2.py, data must be a bytes object rather than a string object. I think we should reopen this issue and change the documentation. Thanks! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: Also, the patch for request.py contains a debug statement, print(data) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: Also, I am not familiar with the backward-comparability requirements of py3k, but orsenthil's patch will break py3k code that relies on data being a string, shouldn't this be mentioned somewhere? Finally, I do not understand why my proposed change, which is to add +if not data: +request.add_unredirected_header('Content-length', '0') so that code that relies on being able to pass a blank string as data (for instance, the code in test_urllib2.py) is still able to do so. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10680] argparse: titles and add_mutually_exclusive_group don't mix (even with workaround)
Changes by Xuanji Li xua...@gmail.com: -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10680 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9938] Documentation for argparse interactive use
Changes by Xuanji Li xua...@gmail.com: -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9938 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10702] bytes and bytearray methods are not documented
Changes by Xuanji Li xua...@gmail.com: -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10702 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10702] bytes and bytearray methods are not documented
Xuanji Li xua...@gmail.com added the comment: Hi, it seems to me that section 4.6.5. Bytes and Byte Array Methods covers this already. It says: Bytes and bytearray objects, being “strings of bytes”, have all methods found on strings, with the exception of encode(), format() and isidentifier(), which do not make sense with these types. For converting the objects to strings, they have a decode() method. Wherever one of these methods needs to interpret the bytes as characters (e.g. the is...() methods), the ASCII character set is assumed. This section covers belpolsky's needs, ie a reader can, from this, understand that bytes have a capitalize method. However, I support 1) Expanding this section to explain more clearly what the methods do to bytes 2) Discuss unicode vs bytes details 3) Mention bytes and bytearrays in 4.6.1 String Methods, because it is quite far away from 4.6.5 As for the suggestion of renaming, if we rename the section, we have to decide what to call a string/byte/bytearray object because it now says, for example, str.something(); also we have to document the encode and decode methods seperately because they are not common to strings and bytes. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10702 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5863] bz2.BZ2File should accept other file-like objects.
Xuanji Li xua...@gmail.com added the comment: Sorry, I'm giving up. The copyright notice for bz2module.c lists Gustavo Niemeyer as one of the holders, is he the maintainer? Maybe he should be notified of this bug. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5863 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10695] telnetlib.Telnet port number int/str inconsistency
Xuanji Li xua...@gmail.com added the comment: Alternatively, I think we can do a conversion to int in Telnet.__init__ (see patch) -- keywords: +patch nosy: +xuanji Added file: http://bugs.python.org/file20035/issue10695.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10695 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10694] zipfile.py end of central directory detection not robust
Xuanji Li xua...@gmail.com added the comment: Hi, I would like to take a look at whether your code works, can you provide an zip file that is currently not read by zipfile but should be? Also, I suggest you submit the code changes as a patch (http://www.python.org/dev/patches/) thanks! -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10694 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10695] telnetlib.Telnet port number int/str inconsistency
Xuanji Li xua...@gmail.com added the comment: Hi, is there any legacy code that would rely on port being stored as a string rather than an integer? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10695 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5863] bz2.BZ2File should accept other file-like objects.
Xuanji Li xua...@gmail.com added the comment: I'll try working on a patch. -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5863 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: eric: sorry, that has been fixed in issue_3243_py3k_7.patch -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: orsenthil: Hi, i don't quite understand why iter() needs to be called explicitly on data? As I understand it, if data is an iterable then you can use a for loop on it directly. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: attaching new patch. this implements the memoryview solution suggested by pitrou. but it does contain this thing: if not request.has_header('Content-length'): if (not hasattr(data, '__read__') and isinstance(data, collections.Iterable)): print(data,is an iterable) try: m = memoryview(data) print(m.itemsize * len(m)) request.add_unredirected_header( 'Content-length', '%d' % (len(m) * m.itemsize)) except TypeError: try: request.add_unredirected_header( 'Content-length', '%d' % len(data)) except TypeError: raise ValueError( No Content-Length specified for iterable body) why is it so nested? because data can support 3 different interfaces: 1) Buffer interface, in that case use memoryview to count bytes 2) Can call len but not buffer: assume len == #bytes 3) Iterable but cannot call len or memoryview: raise ValueError I hope there is a simpler way... -- Added file: http://bugs.python.org/file19891/issue_3243_py3k_5.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: attaching new patch. this implements the memoryview solution suggested by pitrou. but it does contain this thing: if not request.has_header('Content-length'): if (not hasattr(data, '__read__') and isinstance(data, collections.Iterable)): print(data,is an iterable) try: m = memoryview(data) print(m.itemsize * len(m)) request.add_unredirected_header( 'Content-length', '%d' % (len(m) * m.itemsize)) except TypeError: try: request.add_unredirected_header( 'Content-length', '%d' % len(data)) except TypeError: raise ValueError( No Content-Length specified for iterable body) why is it so nested? because data can support 3 different interfaces: 1) Buffer interface, in that case use memoryview to count bytes 2) Can call len but not buffer: assume len == #bytes 3) Iterable but cannot call len or memoryview: raise ValueError I hope there is a simpler way... -- Added file: http://bugs.python.org/file19892/issue_3243_py3k_5.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Changes by Xuanji Li xua...@gmail.com: Removed file: http://bugs.python.org/file19892/issue_3243_py3k_5.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: 2) Can call len but not buffer: assume len == #bytes Why do you need it at all? Hmm, I'm looking at the the tests in urllib2 that fail if we omit this... in test_urllib2 there are tests that do this: req = Request(http://example.com/;, ) and they expect Content-Length to be set to 0... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: And my version too... -- Added file: http://bugs.python.org/file19901/issue_3243_py3k_6.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: thought of a better way, we can check if data is true; this will cover and b. this is in issue_3243_py3k_7.patch -- Added file: http://bugs.python.org/file19902/issue_3243_py3k_7.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: pitrou: actually that seems a bit suspect now... you need to handle 'data' differently depending on its type, and while you can determine the type by finding out when 'data' throws certain exceptions, it doesn't seem like what exceptions were meant for. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10464] netrc module not parsing passwords containing #s.
Xuanji Li xua...@gmail.com added the comment: bumping...can someone review this? The reported bug seems valid enough. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10464 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: I don't fully understand Lib/urllib/request.py either, I just ported it and ran the unittests... it seems like what it does is that if you send an iterator through as 'data' you can't know the length in advance, and rather than let the len(data) raise an exception catlee thought it's better to raise an exception to tell the user exactly why the code failed (ie, because the user sent an iterator and there's no way to meaningfully find the Content-Length of that). As for the catching exceptions vs using isinstance: I thought about it for a while, I think something like this feels right to me: try: self.sock.sendall(data) except TypeError: if isinstance(data, collections.Iterable): for d in t: self.sock.sendall(d) else: raise TypeError(data should be a bytes-like object or an iterable, got %r % type(it)) anyway, calling iter(data) is equivalent to calling data.__iter__(), so catching the exception is equivalent to hasattr(data, '__iter__'), which is roughly the same as isinstance(data, collections.Iterable). so we try the most straightforward method (sending everything) then if that fails, data is either an iterator or a wrong type. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: davide: yeah, hasattr(lol, '__next__') == False, even though strings are Iterable; so for strings and other such sequences the len(data) line will be executed. So technically we shouldn't say No Content-Length specified for iterable body but we should say No Content-Length specified for iterable body that is not a sequence. Basically, this whole patch (both parts of it) will be much better off iif there is a clean way to say a is an iterable but a is not a sequence, because even though b'this is a message' is Iterable, we want to treat it differently compared to, say, a generator object; we do NOT want to use the Iterator features (iter, next) of it, we want to use the sequencey features (by sending the whole chunk of it, by calling len) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: So, reading all your comments, I gather that my proposed patch for client.py which is try: self.sock.sendall(data) except TypeError: if isinstance(data, collections.Iterable): for d in t: self.sock.sendall(d) else: raise TypeError(data should be a bytes-like object or an iterable, got %r % type(it)) is ok, because it avoids using hasattr to test for Iterable and avoids isinstance() to check for specific types (str, bytes...) but instead uses exceptions (as pitrou suggested)? if that is ok with everyone, I just need to work more on request.py to remove the hasattr; I'll probably use the memoryview solution suggested by pitrou. just to confirm: we WANT array.array(I, [1,2,3]) to have a content-length of 12, right? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: What a timely coincidence. I'll try out the change soon. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: Changed according to Raymond's suggestion. I realized that there are some classes (str, bytes, array.array) that are iterable but should not be handled by the iteration logic provided by catlee. eg: if we iterate through b'a message' we'd get a bunch of ints and sending them is wrong. patch attached. -- Added file: http://bugs.python.org/file19873/issue_3243_py3k_2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: pitrou: that sounds good. I attached another patch. -- Added file: http://bugs.python.org/file19879/issue_3243_py3k_3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10496] import site failed when Python can't find home directory
Xuanji Li xua...@gmail.com added the comment: I tried running bug.c using the svn head of python and got this: Could not find platform independent libraries prefix Could not find platform dependent libraries exec_prefix Consider setting $PYTHONHOME to prefix[:exec_prefix] Fatal Python error: Py_Initialize: Unable to get the locale encoding LookupError: no codec search functions registered: can't find encoding Aborted -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10496 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: Hi, attached is a ported version of the patch that applies against py3k. -- nosy: +xuanji Added file: http://bugs.python.org/file19852/issue_3243_py3k.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3243] Support iterable bodies in httplib
Xuanji Li xua...@gmail.com added the comment: Hi Raymond, I assume you're referring to catlee's patch? 'str' has been changed to 'data' in python 3.2 While porting the patch I ran into this issue, which is that isinstance(str, collections.Iterable) doesn't behave exactly like hasattr(str,'next') hasattr(lol, '__next__') False isinstance(lol, collections.Iterable) True so using the isinstance method would actually match against strings, which iirc would make the program fail. I can confirm later if needed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3243 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10516] Add list.clear() and list.copy()
Xuanji Li xua...@gmail.com added the comment: Hi, I'm also looking at listobject.c also... if we want list.clear() to behave exactly like del list[], we may be able to just call list_ass_slice on the list. Similarly for list.copy which should behave like a=l[:] -- nosy: +xuanji ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10516 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10516] Add list.clear() and list.copy()
Xuanji Li xua...@gmail.com added the comment: That's good if it's so... can you explain why list_clear doesn't guarantee that the list is empty? Why would XDECREF populate the list? I don't quite understand it. eli: are you writing a patch for this? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10516 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10464] netrc module not parsing passwords containing #s.
Xuanji Li xua...@gmail.com added the comment: The patch attached (issue_10464_fix) moves handling of the '#' character from shlex to netrc, and makes netrc consider as comments lines whose first not-whitespace character is '#' instead of all text following '#' (which is what shlex does and which causes this bug). It also includes a test case. -- Added file: http://bugs.python.org/file19818/issue_10464_fix.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10464 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10366] Remove unneeded '(object)' from 3.x class examples
Xuanji Li xua...@gmail.com added the comment: Hi eric, what doc change are you referring to? -- status: pending - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10366 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10464] netrc module not parsing passwords containing #s.
Xuanji Li xua...@gmail.com added the comment: Included test case for the reported bug. Test fails on my machine. Also split up test_case_1 (in order to put in the new test case cleanly) -- keywords: +patch nosy: +xuanji Added file: http://bugs.python.org/file19658/issue_10464_testcase.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10464 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10464] netrc module not parsing passwords containing #s.
Changes by Xuanji Li xua...@gmail.com: Removed file: http://bugs.python.org/file19658/issue_10464_testcase.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10464 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10464] netrc module not parsing passwords containing #s.
Xuanji Li xua...@gmail.com added the comment: Sorry, patch had a mistake -- Added file: http://bugs.python.org/file19666/issue_10231_testcase.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10464 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10464] netrc module not parsing passwords containing #s.
Xuanji Li xua...@gmail.com added the comment: The issue seems to be that when shlex (the lexer that netrc uses) sees a '#' character it thinks that the rest of the line is a comment. I am not sure what the behavior of netrc should be - should it treat '#' as beginning a comment only if its the first non-whitespace character on a line? Should shlex be changed to reflect this? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10464 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10366] Remove unneeded '(object)' from 3.x class examples
Xuanji Li xua...@gmail.com added the comment: Attached a patch to implement the suggested changes on 3.2. If the patch is ok I can do the same for 3.1. -- keywords: +patch nosy: +xuanji Added file: http://bugs.python.org/file19591/issue10366_remove_unneeded_object_py3.2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10366 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com