[issue46913] UBSAN: test_ctypes, test_faulthandler and test_hashlib are failing
Martin Panter added the comment: The ctypes overflow is probably the same as described in Issue 28169 and Issue 15119 -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue46913> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46756] Incorrect authorization check in urllib.request
Martin Panter added the comment: Maybe the same as Issue 42766? -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue46756> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46738] Allow http.server to emit HTML 5
Change by Martin Panter : -- superseder: -> Generate HTML 5 with SimpleHTTPRequestHandler.list_directory ___ Python tracker <https://bugs.python.org/issue46738> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46517] Review exception handling in urllib
Martin Panter added the comment: The linked code is for urllib.parse.urlencode, looking something like try: if len(query) and not isinstance(query[0], tuple): raise TypeError except TypeError: ty, va, tb = sys.exc_info() raise TypeError("not a valid non-string sequence " "or mapping object").with_traceback(tb) I guess it raises twice so that the error message is not duplicated in the code. The author probably also wants the TypeError initially raised from the "len(query)" and "query[0]" operations to get the same "not a valid . . ." message. Regarding the OSError, originally it was catching socket.error and raising IOError. I guess someone only wanted the caller to have catch IOError and not need to import the socket module. Later these exception types became aliases of each other. Anyway, the URLopener class is documented as deprecated, so is it really worth changing anything in that? -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue46517> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46319] datetime.utcnow() should return a timezone aware datetime
Martin Panter added the comment: Perhaps this is a duplicate of Issue 12756? -- nosy: +martin.panter superseder: -> datetime.datetime.utcnow should return a UTC timestamp ___ Python tracker <https://bugs.python.org/issue46319> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45585] Gzipping subprocess output produces invalid .gz file
Martin Panter added the comment: The subprocess module only uses the file object to get a file handle by calling the "fileno" method. See Issue 19992 about documenting this. For Python to compress the output of the child process, you would need a pipe. Gzip file objects provide the "fileno" method, but it just returns the underlying file descriptor. Data written to that file descriptor would normally already be compressed by Python and goes straight to the OS. There is also Issue 24358 opened about whether "fileno" should be implemented. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue45585> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45523] Python3 ThreadingHTTPServer fails to send chunked encoded response
Martin Panter added the comment: Looks like you forgot to encode the length of ten in hexadecimal. I don't think the HTTP server module has any special handling for chunked responses, so this up to the user and isn't a bug in Python. -- nosy: +martin.panter resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue45523> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45349] configparser.ConfigParser: 2 newlines at end of file (EOF)
Martin Panter added the comment: Looks like the same as Issue 32917. I presume there are two newlines at the end of the file because there are two newlines following every config section. IMO this is a minor cosmetic annoyance, just like writing a key with an empty value gets you a trailing space after the equals sign at the end of the line. Not worth changing as a bug fix, and not worth a special option, but maybe okay to change if the code is simple and it doesn't harm compatibility. -- nosy: +martin.panter resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> ConfigParser writes a superfluous final blank line ___ Python tracker <https://bugs.python.org/issue45349> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45170] tarfile missing cross-directory checking
Martin Panter added the comment: Issue 21109 has been open for a while and is the same as this, if I am not mistaken. -- nosy: +martin.panter resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> tarfile: Traversal attack vulnerability ___ Python tracker <https://bugs.python.org/issue45170> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44146] Format string fill not handling brace char
Martin Panter added the comment: Another workaround: >>> '{:{brace}>10d}'.format(5, brace='{') '{5' -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue44146> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44228] [urllib] Error with handling of urllib.parse.quote. Terminates halfway
Martin Panter added the comment: I presume this is because you are running a Unix shell, and it's nothing to do with Python. Look up how quoting and variable substitution with dollar signs $ works. $ set -o nounset $ python3 -c "import urllib.parse; print (urllib.parse.quote('ab$cd&efg#hij$klm'))" bash: cd: unbound variable Works fine in the Python interpreter: >>> import urllib.parse; print (urllib.parse.quote('ab$cd&efg#hij$klm')) ab%24cd%26efg%23hij%24klm -- nosy: +martin.panter resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue44228> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44007] urlparse("host:123", "http") inconsistent between 3.8 and 3.9
Martin Panter added the comment: I suspect this comes from Issue 27657. Consider how similar URLs like tel:123 or javascript:123 should be parsed. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue44007> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak
Martin Panter added the comment: Anselm's pull request PR 15175 looked hopeful to me. I've been using those changes in our builds at work for a while. -- ___ Python tracker <https://bugs.python.org/issue37788> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34915] LWPCookieJar.save() creates *.lwp file in 644 mode
Martin Panter added the comment: I don't have a strong opinion, but it does seem a sensible change that matches the high-level nature of the "cookiejar" module, with low risk of users relying on the current file permissions. On the other hand, the "curl" command seems to use the default mode when creating a cookies file (in Netscape a.k.a. Mozilla format): $ curl --cookie-jar cookies https://www.google.com/ [. . .] $ ls -l cookies -rw-r--r-- 1 vadmium vadmium 418 Mar 14 17:12 cookies The MozillaCookieJar class also seems to use the default file mode. I suppose it should be changed as well as the LWP class. -- components: -SSL ___ Python tracker <https://bugs.python.org/issue34915> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43292] xml.ElementTree iterparse filehandle left open
Change by Martin Panter : -- type: security -> resource usage ___ Python tracker <https://bugs.python.org/issue43292> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43292] xml.ElementTree iterparse filehandle left open
Martin Panter added the comment: Perhaps this can be handled with Issue 25707, which is open for adding an API to close the file, similar to how "os.scandir" iterator implements a context manager and "close" method. -- nosy: +martin.panter superseder: -> Add the close method for ElementTree.iterparse() object ___ Python tracker <https://bugs.python.org/issue43292> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43375] memory leak in threading ?
Martin Panter added the comment: Sounds the same as Issue 37788, which is still open. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue43375> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak
Change by Martin Panter : -- keywords: +3.7regression ___ Python tracker <https://bugs.python.org/issue37788> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43050] threading timer memory leak
Martin Panter added the comment: Perhaps this is caused by Issue 37788. Python 3.7.4 introduced a leak for any thread that doesn't get its "join" method called. Timer is a subclass of Thread, so to confirm, see if calling "timer.join()" after "cancel" will make the leak go away. -- nosy: +martin.panter resolution: -> duplicate superseder: -> fix for bpo-36402 (threading._shutdown() race condition) causes reference leak type: performance -> resource usage ___ Python tracker <https://bugs.python.org/issue43050> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42263] Removing thread reference in thread results in leaked reference
Martin Panter added the comment: Maybe this is related to (or duplicate of) Issue 37788? Python 3.7 has a regression where threads that are never joined cause leaks; previous code was written assuming you didn't need to join threads. Do you still see the leak even if you don't clear the "threads" list (change the target to a no-op), or if you never create a list in the first place? -- ___ Python tracker <https://bugs.python.org/issue42263> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42263] Removing thread reference in thread results in leaked reference
Change by Martin Panter : -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue42263> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42094] isoformat() / fromisoformat() for datetime.timedelta
Martin Panter added the comment: There is related discussion in Issue 41254, about duration formats more generally. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue42094> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41983] Missing Documentation AF_PACKET
Martin Panter added the comment: According to the documentation at <https://docs.python.org/3.8/library/socket.html#socket.AF_PACKET> and Issue 25041 it is only available on Linux. What documentation are you looking at? -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue41983> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42062] Usage of HTTPResponse.url
Martin Panter added the comment: There is a comment in the HTTPResponse class regarding these methods: # For compatibility with old-style urllib responses. They were there for the "urlopen" API in "urllib.request", not for the "http.client" module on its own. I expect the "url" attribute is set by the "urlopen" code. However more recently (Issue 12707) the "url" attribute and "geturl" method were documented in the HTTPResponse documentation, which is awkward. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue42062> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41767] KeyError exception is more difficult to read due to quoting
Martin Panter added the comment: Perhaps a duplicate of Issue 2651, closed because it was too hard to fix without breaking compatibility. -- nosy: +martin.panter superseder: -> Strings passed to KeyError do not round trip ___ Python tracker <https://bugs.python.org/issue41767> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41695] http.cookies.SimpleCookie.parse could not parse cookies when one cookie value is json
Martin Panter added the comment: Perhaps this is a duplicate of Issue 27674, where I think parsing is aborted when a double-quote is seen? -- nosy: +martin.panter superseder: -> Quote mark breaks http.cookies, Cookie.py processing ___ Python tracker <https://bugs.python.org/issue41695> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41450] OSError is not documented in ssl library, but still can be thrown
Martin Panter added the comment: Issue 31122 is also open about fixing this long-term, but I agree it would be good to document this quirk / bug. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue41450> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41345] Remote end closed connection without response
Martin Panter added the comment: Previous report about Requests to the Python bug tracker: Issue 33620. I suspect this is an unavoidable race condition with trying a POST (or other non-idempotent) request on an idle HTTP connection. I think it has to be up to the higher-level application or user to decide if it is safe to retry a POST request. Otherwise you risk e.g. accidentally ordering two pizzas because the server received two POST requests but something interfered with the response of the first response. On the other hand, I noticed some browsers seem to automatically retry a POST once if it is interrupted, which makes me uneasy. A concrete example of the problem is a firmware upload that triggers a reboot. If the reboot is too quick and prevents the POST response being sent, I found that a web browser will repeat the firmware upload once more after my firmware boots up again. If it is not safe to retry the POST request, other options would be to avoid the server thinking the connection is stale: * always do the POST request on a fresh HTTP connection * "ping" the connection with a dummy request (e.g. OPTIONS, HEAD, or GET) immediately before the POST request Another option that comes to mind is to try using the 100 Continue mechanism, but this is not a general solution and depends on the application. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue41345> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18861] Problems with recursive automatic exception chaining
Change by Martin Panter : -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue18861> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41254] Add to/from string methods to datetime.timedelta
Martin Panter added the comment: I don't know how much support this will get since there is already a str(timedelta) operation defined with a different format. But I don't like that format much. The day[s] part is too verbose, the H:MM:SS part could too easily be interpreted as D:HH:MM, and the result for negative deltas is horrible (-43 days, 23:59:55; see Issue 38701). My favourite format for a duration is usually the HTML 5 format like 1w 0d 12h 0m 27s Another option is ISO 8601 format: P1W0DT12H0M27S But both of these standards only go down to the seconds unit, so 50 ms has to be 0.05s or PT0.05S. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue41254> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40657] Resource leaks with threading.Thread
Martin Panter added the comment: Perhaps this is the same as Issue 37788, introduced in 3.7. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue40657> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40299] os.dup seems broken with execvp (LINUX)
Martin Panter added the comment: The file descriptor created by "os.dup" is not inherited by child processes by default since Python 3.4. https://docs.python.org/3/library/os.html#os.dup Does it work if you use "os.set_inheritable" or "os.dup2" (which apparently sets it inhertiable by default)? -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue40299> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26527] CGI library - Using unicode in header fields
Martin Panter added the comment: I’m not an expert on the topic, but it sounds like this might be a duplicate of Issue 23434, which has more discussion. -- nosy: +martin.panter resolution: -> duplicate status: open -> pending superseder: -> support encoded filename in Content-Disposition for HTTP in cgi.FieldStorage ___ Python tracker <https://bugs.python.org/issue26527> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39780] Add HTTP Response code 103
Martin Panter added the comment: See also Issue 39509, proposing to add 103 and "425 Too Early" -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue39780> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39717] Fix exception causes in tarfile module
Martin Panter added the comment: Please don’t use “from None” in library code. It hides exceptions raised by the calling application that would help debugging. E.g. <https://bugs.python.org/issue30097#msg293185> -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue39717> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35318] Check accuracy of str() doc string for its encoding argument
Martin Panter added the comment: Closing in favour of Issue 39574 where a new wording is proposed -- nosy: +martin.panter resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> str.__doc__ is misleading ___ Python tracker <https://bugs.python.org/issue35318> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39353] Deprecate the binhex module, binhex4 and hexbin4 standards
Martin Panter added the comment: Thanks Victor -- ___ Python tracker <https://bugs.python.org/issue39353> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39353] Deprecate the binhex module, binhex4 and hexbin4 standards
Martin Panter added the comment: Of course I would prefer “crc_hqx” to stay, because we use it at work. But I understand if you think it is not popular enough to justify maintaining it. But I was more asking if the deprecation notice should point the way forward. This function is no longer recommended, so what should users do instead? Or at least explain why it is deprecated. In my case, I may eventually write or resurrect a simple Python CRC implementation that shifts one bit at a time. But other people may desire a faster C implementation. -- ___ Python tracker <https://bugs.python.org/issue39353> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39353] Deprecate the binhex module, binhex4 and hexbin4 standards
Martin Panter added the comment: Building and verifying the checksum in "RTA protocol" that uses this: <https://rms.nsw.gov.au/business-industry/partners-suppliers/documents/specifications/tsi-sp-003.pdf>. But I understand CRC-CCITT is one of the two popular 16-bit CRC polynomials, used in many other places, according to <https://en.wikipedia.org/wiki/Cyclic_redundancy_check#Polynomial_representations_of_cyclic_redundancy_checks>. -- ___ Python tracker <https://bugs.python.org/issue39353> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39353] Deprecate the binhex module, binhex4 and hexbin4 standards
Martin Panter added the comment: Is there a recommended replacement for calculating CRC-CCITT? Do it yourself in Python code, or use a particular external module? -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue39353> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37193] Memory leak while running TCP/UDPServer with socketserver.ThreadingMixIn
Martin Panter added the comment: FTR I have been trialling a patched Python 3.7 based on Maru's changes (revision 6ac217c) + review suggestions, and it has reduced the size of the leak (hit 1 GB over a couple days, vs only 60 MB increase over three days). The remaining leak could be explained by Issue 37788. -- ___ Python tracker <https://bugs.python.org/issue37193> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak
Change by Martin Panter : -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue37788> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37193] Memory leak while running TCP/UDPServer with socketserver.ThreadingMixIn
Martin Panter added the comment: Another workaround might be to set the new "block_on_close" flag (Issue 33540) to False on the server subclass or instance. Victor: Replying to <https://bugs.python.org/issue37193#msg345817> "What do I think of also using a weakref?", I assume you mean maintaining "_threads" as a WeakSet rather than a list object. That seems a nice way to solve the problem, but it seems redundant to me if other code such as Maru's proposal was also added to clean up the list. -- ___ Python tracker <https://bugs.python.org/issue37193> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38710] unsynchronized write pointer in io.TextIOWrapper in 'r+' mode
Martin Panter added the comment: Previously Issue 12215 and a couple of other duplicates were opened about this. Writing after reading with TextIOWrapper doesn't work as people expect. The report was closed apparently because Victor thought there wasn't enough interest in it. FWIW the seek-then-write workaround will probably work for most common codecs, but would suffer the same problems discussed in Issue 26158 for codecs like UTF-7 and ISO-2022 that would need the encoder state constructed from the decoder state. -- nosy: +martin.panter superseder: -> TextIOWrapper: issues with interlaced read-write ___ Python tracker <https://bugs.python.org/issue38710> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38831] urllib.request header characters being changed to lowercase
Martin Panter added the comment: I suggest to keep the discussion with Issue 12455 -- nosy: +martin.panter superseder: -> urllib2 forces title() on header names, breaking some requests ___ Python tracker <https://bugs.python.org/issue38831> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29979] cgi.parse_multipart is not consistent with FieldStorage
Change by Martin Panter : -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue29979> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34226] cgi.parse_multipart() requires undocumented CONTENT-LENGTH in Python 3.7
Martin Panter added the comment: Looks like the change causing this is revision cc3fa20. I would remove the reference to pdict['CONTENT-LENGTH']. -- keywords: +3.7regression nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue34226> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37477] NamedTemporaryFile can hang on windows
Change by Martin Panter : -- resolution: -> duplicate superseder: -> tempfile module misinterprets access denied error on Windows ___ Python tracker <https://bugs.python.org/issue37477> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37477] NamedTemporaryFile can hang on windows
Martin Panter added the comment: Perhaps a duplicate of Issue 22107? -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue37477> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37424] subprocess.run timeout does not function if shell=True and capture_output=True
Martin Panter added the comment: Same thing going on as in Issue 30154. The shell is probably spawning the “sleep” command as a child process (grandchild of Python), and waiting for it to exit. When Python times out, it will kill the shell process, leaving the grandchild as an orphan. The “sleep” process will still be running and probably holds the “stdout” and/or “stderr” pipes open, and Python will wait indefinitely to be sure it has captured all the output to those pipes. Also see Issue 26534 proposes APIs to kill a process group rather than the single child process. -- nosy: +martin.panter resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> subprocess.run with stderr connected to a pipe won't timeout when killing a never-ending shell commanad ___ Python tracker <https://bugs.python.org/issue37424> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37193] Memory leak while running TCP/UDPServer with socketserver.ThreadingMixIn
Martin Panter added the comment: Looking at the code, this would be caused by Issue 31233. I expect 3.7+ is affected. 3.6 has similar code, but the leaking looks to be disabled by default. 2.7 doesn't collect a "_threads" list at all. Looks like Victor was aware of the leak when he changed the code: <https://bugs.python.org/issue31233#msg304619>, but maybe he pushed the code and then forgot about the problem. A possible problem with Norihiro's solution is modifying the "_threads" list from multiple threads without any synchronization. (Not sure if that is a problem, or is it guaranteed to be okay due to GIL etc?) Also, since the thread is removing itself from the list, it will still run a short while after the removal, so there is a window when the "server_close" method will not wait for that thread. Might also defeat the "dangling thread" accounting that I believe was Victor's motivation for his change. Wei's proposal is to check for cleaning up when a new request is handled. That relies on a new request coming in to free up memory. Perhaps we could use similar strategy to the Forking mixin, which I believe cleans up expired children periodically, without relying on a new request. -- keywords: +3.7regression nosy: +martin.panter, vstinner ___ Python tracker <https://bugs.python.org/issue37193> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31233] socketserver.ThreadingMixIn leaks running threads after server_close()
Martin Panter added the comment: FYI the change here to remember all the thread objects ever created looks to be the cause of the memory leak reported in Issue 37193 -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue31233> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37290] Mistranslation (Japanese)
Change by Martin Panter : -- nosy: +cocoatomo title: Mistranslation -> Mistranslation (Japanese) ___ Python tracker <https://bugs.python.org/issue37290> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37176] super() docs don't say what super() does
Martin Panter added the comment: Some of the problems brought up here (which sibling or subclass, and which parameter’s MRO) also came up a few years ago in Issue 23674. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue37176> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37040] checking for membership in itertools.count enters infinite loop with no way to exit
Martin Panter added the comment: Problems with long-running iterators are already discussed in: Issue 31815: rejected proposal to check for interrupts Issue 33939: proposal to flag iterators as being infinite -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue37040> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36863] argparse doesn't like options in the middle of arguments
Martin Panter added the comment: The “cmd” module doesn’t use “argparse” as far as I can see. You might have to provide more information or code for someone to make sense of or reproduce your bug. Also, see Issue 14191 which added new “parse_[known]_intermixed_args” APIs in 3.7, and have a look at Issue 15112, about intermixing options between particular kinds of positional parameters. -- nosy: +martin.panter status: open -> pending ___ Python tracker <https://bugs.python.org/issue36863> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36760] subprocess.run fails with capture_output=True and stderr=STDOUT
Martin Panter added the comment: Python 3.7 added the "capture_output" parameter, for Issue 32102. Before that change, you could use "subprocess.PIPE": https://docs.python.org/3.6/library/subprocess.html#subprocess.run “To [capture output], pass PIPE for the ‘stdout’ and/or ‘stderr’ arguments” Since "capture_output" was added, it looks like you can still pass "subprocess.PIPE" on your own, but the documentation now only gives subtle hints that this might be supported. This was also brought up in Issue 33319. -- nosy: +bbayles, martin.panter ___ Python tracker <https://bugs.python.org/issue36760> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36726] Empty select() on windows gives error.
Martin Panter added the comment: I think this is a duplicate of Issue 29256. Issue 25680 also discusses platform differences with no file descriptors. -- nosy: +martin.panter resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> Windows select() errors out when given no fds to select on, which breaks SelectSelector ___ Python tracker <https://bugs.python.org/issue36726> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35824] http.cookies._CookiePattern modifying regular expressions
Martin Panter added the comment: Test_http_cookies line 19 has the following test case: {'data': 'keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"', 'dict': {'keebler' : 'E=mc2; L="Loves"; fudge=\012;'}, 'repr': '''''', 'output': 'Set-Cookie: keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"'} This is similar to an example in the documentation: >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";') >>> print(C) Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;" If you break parsing of this string in the “load” method, you break documented behaviour. The “http.cookie” module is documented to follow RFC 2109. I believe the strings are valid by RFC 2109, in which the value is allowed to use the HTTP “quoted-string” format. -- ___ Python tracker <https://bugs.python.org/issue35824> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33017] Special set-cookie setting will bypass Cookielib
Martin Panter added the comment: I think LCatro is saying that Python should accept the cookies and discard only the offending attributes. This makes sense to me and tends to agree with the specifications, but the three cases seem all seem unimportant to me. PoC 1, Max-age: >>> from urllib2 import Request >>> from test.test_cookielib import FakeResponse >>> cookies = CookieJar(DefaultCookiePolicy()) >>> request = Request('http://127.0.0.1/requests_test.php') >>> cookies.extract_cookies(FakeResponse(()), request) # Issue 12144 >>> cookies.make_cookies(FakeResponse(('Set-Cookie: test=123; max-age=a',)), >>> request) # No cookies returned [] RFC 6265 says Max-age should be ignored if not does not start with a digit or minus sign: <https://tools.ietf.org/html/rfc6265#section-5.2.2>. Netscape did not specify Max-age at all. So I agree that the cookie should be retained. PoC 2, Domain: You have to omit the equals sign to satisfy “v is None” and discard the cookie record, otherwise “v” is just an empty string '': >>> cookies.make_cookies(FakeResponse(('Set-Cookie: test=123; domain=;',)), >>> request) # v == '' [Cookie(version=0, name='test', value='123', port=None, port_specified=False, domain='.', domain_specified=True, domain_initial_dot=False, path='/', path_specified=False, secure=False, expires=None, discard=True, comment=None, comment_url=None, rest={}, rfc2109=False)] >>> cookies.make_cookies(FakeResponse(('Set-Cookie: test=123; domain;',)), >>> request) # v is None [] RFC 6265 says both these cases should be treated the same, and recommends ignoring Domain in these cases. PoC 3, Version: >>> cookies.make_cookies(FakeResponse(('Set-Cookie: test=123; version=a;',)), >>> request) # No cookies returned [] The Version attribute is only specified by RFC 2109. Since the IETF has obsoleted it, I suggest to deprecate RFC 2109 support in the Python module. That way, if a real problem is demonstrated, we can remove the parts that are causing the problem. -- nosy: +martin.panter priority: normal -> low ___ Python tracker <https://bugs.python.org/issue33017> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12144] cookielib.CookieJar.make_cookies fails for cookies with 'expires' set
Martin Panter added the comment: Karthikeyan, it looks like your test will pass even when the bug is not fixed. A test calling code that writes error message does not necessarily mean the test itself will fail, I don’t think. I suggest you look at raising an exception when the UserWarning is triggered, and/or check that the expected cookie is returned with the right “expires” value. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue12144> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1564508] RFC 2965 BaseCookie does not support "$Port"
Martin Panter added the comment: The original report comes from <https://code.djangoproject.com/ticket/2806>. Anders was trying to parse a HTTP request Cookie field, something like: BaseCookie('sessionid=a2be2e7debe71af8d88d350c4d14d768;$Path=/;$Domain=192.168.0.2;$Port="8000"') The problem is that Cookie.py assumes names beginning with a dollar sign ($) are reserved attributes of a previous cookie-pair, rather than arbitrary cookie names. It is obvious that this was intended to support RFC 2965, although it is not documented. The module has a hard-coded list of reserved attribute names, and Port is not one of them. IMO it would be better to treat (unknown) reserved attributes such as $Port as ordinary cookie names, and start a new “morsel”. Ignoring them would also be a better option than rejecting the whole cookie field. The dollar sign is valid for a cookie name (token) according to RFC 2109, RFC 6265, and the Netscape specification. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue1564508> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23930] http.cookies.SimpleCookie doesn't parse comma-only separated cookies correctly
Change by Martin Panter : -- resolution: -> rejected status: open -> pending ___ Python tracker <https://bugs.python.org/issue23930> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23298] Add ArgumentParser.add_mutually_dependence_group
Change by Martin Panter : -- superseder: -> Add "necessarily inclusive" groups to argparse ___ Python tracker <https://bugs.python.org/issue23298> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22742] IDLE shows traceback when printing non-BMP character
Martin Panter added the comment: I haven’t looked at the code, but I suspect Idle implements a custom “sys.displayhook”: >>> help(sys.displayhook) Help on function displayhook in module idlelib.rpc: displayhook(value) Override standard display hook to use non-locale encoding >>> sys.displayhook('\N{ROCKET}') '\U0001f680' >>> sys.__displayhook__('\N{ROCKET}') Traceback (most recent call last): File "", line 1, in sys.__displayhook__('\N{ROCKET}') File "/usr/lib/python3.5/idlelib/PyShell.py", line 1344, in write return self.shell.write(s, self.tags) UnicodeEncodeError: 'UCS-2' codec can't encode characters in position 1-1: Non-BMP character not supported in Tk -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue22742> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36711] duplicate method definition in Lib/email/feedparser.py
Martin Panter added the comment: This is caused by Serhiy’s first change to 2.7 in Issue 21448. Compare Mercurial rev. 1b1f92e39462 (3.4 branch) with ba90bd01c5f1 (2.7). In 2.7, he applied the Python 3 version of the code, which used “str.splitlines” rather than a regular expression “NLCRE_crack.split”. This seems reasonable, but the old Python 2 code remains under a spurious “def pushlines” block. I think that first block of “pushlines” can safely be removed, just leaving the second version, a single line of code like in Python 3. -- components: +email -Library (Lib) nosy: +barry, martin.panter, r.david.murray ___ Python tracker <https://bugs.python.org/issue36711> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36701] module 'urllib' has no attribute 'request'
Martin Panter added the comment: The “urllib” package also contains “urllib.parse”, which is a lot more lightweight than “urllib.request”. In a quick experiment, importing “urllib.request” is more than 2 times slower than importing “urllib.parse” on its own. And importing “urllib” by itself is not much faster, so I guess a lot of the time is unavoidable Python startup, and “urllib.request” is probably many times slower than “urllib.parse”. The reason for the slowness is the dependencies and initialization. The “urllib.parse” module only imports a few commonly-used modules. On the other hand, importing “urllib.request” imports many heavyweight high-level modules directly and indirectly (email submodules in particular, also things like SSL, multithreading, HTTP client, temporary files). Some of these dependencies also compile lots of regular expressions at import time. The slowdown can be a problem for things like command-line programs. Just today I found “circusd --help” on a Raspberry Pi took ~5 s to produce output. The case of “os.path” is different: it isn’t a submodule of “os”. It is just a pointer to “posixpath”, “ntpath”, etc, depending on “os.name”. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue36701> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33632] undefined behaviour: signed integer overflow in threadmodule.c
Martin Panter added the comment: Victor, if you run the test suite, one of the test cases should trigger the overflow. I used to compile with Undefined Behaviour Sanitizer to print messages when these errors occur; see <https://bugs.python.org/issue1621#msg271118> for my setup at the time. I presume Antoine did something similar. I do not remember, but suspect the test case might be the following lines of “BaseLockTests.test_timeout” in Lib/test/lock_tests.py, testing a fraction of a second less than PY_TIMEOUT_MAX: # TIMEOUT_MAX is ok lock.acquire(timeout=TIMEOUT_MAX) Perhaps reducing PY_TIMEOUT_MAX by a few centuries would be one way to avoid the problem. In my patch I avoided the problem by rearranging the arithmetic, so that the timeout value is only compared and reduced, never added. -- ___ Python tracker <https://bugs.python.org/issue33632> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17267] datetime.time support for '+' and '-'
Martin Panter added the comment: A real use case that I have had was with a protocol to activate a device with a daily schedule. The protocol takes start and end hours and minutes of the day. To test the device by activating it over the next few minutes, my ideal way would have taken the current time (according to the device controller) as a “time” object, and added a couple of minutes using “timedelta”. In the end I think I made my protocol API accept both “time” and “timedelta" objects, because I found “timedelta” more flexible for calculations, but the “time” class more natural in other cases. The start and end times are local times, and daylight saving could come into play, but in reality I won’t be testing the device at 3 a.m. on a Sunday morning. If I did care, I would have to add my own logic with knowledge of the date and daylight saving, to raise an exception. I agree with Alexander about supporting the difference between two “time” instances. The result should be a non-negative “timedelta”, at least zero, and strictly less than 24 h. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue17267> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36600] re-enable test in nntplib
Martin Panter added the comment: Does the test still depend on real-world posts? If so, see Issue 19613. I don’t think the problem has been fixed. -- nosy: +martin.panter superseder: -> test_nntplib: sporadic failures, test_article_head_body() ___ Python tracker <https://bugs.python.org/issue36600> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30458] [security][CVE-2019-9740][CVE-2019-9947] HTTP Header Injection (follow-up of CVE-2016-5699)
Martin Panter added the comment: Gregory, I haven’t tried recent Python code, but I expect the problem with percent decoding is still there. If you did try my example, what results did you see? Be aware that these techniques only work if the OS co-operates and connects to localhost when you give it the longer host string. At the moment I have glibc 2.26 on x86-64 Linux. In the Python 3 master branch, the percent-encoding should be decoded in “urllib.request.Request._parse”: def _parse(self): ... self.host, self.selector = _splithost(rest) if self.host: self.host = unquote(self.host) Then in “AbstractHTTPHandler.do_request_” the decoded host string becomes the “Host” header field value, without any encoding: def do_request_(self, request): host = request.host ... sel_host = host ... if not request.has_header('Host'): request.add_unredirected_header('Host', sel_host) Perhaps one solution to both my version and Orange’s original version is to encode the “Host” header field value properly. This might also apply to the “http.client” code. -- ___ Python tracker <https://bugs.python.org/issue30458> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36293] Nonblocking read sys.stdin raises error
Change by Martin Panter : -- resolution: -> duplicate ___ Python tracker <https://bugs.python.org/issue36293> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36293] Nonblocking read sys.stdin raises error
Martin Panter added the comment: I wasn’t sure about closing it, in case Cyker came back with more details. E.g. what was the use case? Were they mislead by the documentation? Do they just think the error should be different, or do they think there should be no error in this case? But I suppose we can close this and keep discussion about non-blocking text input together in the existing reports. -- stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue36293> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35403] support application/wasm in mimetypes and http.server
Change by Martin Panter : -- superseder: -> http.server module sets incorrect mimetype for WebAssembly files ___ Python tracker <https://bugs.python.org/issue35403> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35403] support application/wasm in mimetypes and http.server
Martin Panter added the comment: According to Issue 34758, this was already added to 3.8’s “mimetypes”. -- nosy: +martin.panter resolution: -> out of date stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue35403> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36483] Missing line in documentation example
Martin Panter added the comment: Did you read the bracketed paragraph directly below, or try running the code with your “break” statement? I expect it would stop at the first prime number (two). But the output continues with more prime numbers. -- nosy: +martin.panter resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue36483> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36464] Python 2.7 build install fails intermittently with -j on MacOS
Martin Panter added the comment: On Linux, Gnu’s “install” command is happy if the target directory already exists; it just changes the mode (-m) etc. So the race isn’t a big deal. This is like the race I described (theoretical at the time) at <https://bugs.python.org/issue25696#msg255393>, although that is about $(LIBPC) not $(LIBDIR). I suggested adding a separate target (a bit like Paul’s “make-directories” suggestion; see my -4.patch in that bug), but it didn’t get much support. A more conservative patch would be a phony target that retains the existing “if / echo / install” logic. -- nosy: +martin.panter stage: -> needs patch ___ Python tracker <https://bugs.python.org/issue36464> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33319] `subprocess.run` documentation doesn't tell is using `stdout=PIPE` safe
Martin Panter added the comment: This is a regression in the 3.7+ documentation. It previously said “To [capture output], pass PIPE for the ‘stdout’ and/or ‘stderr’ arguments”. This was removed by Bo Bayles in Issue 32102. -- keywords: +3.7regression nosy: +bbayles, gregory.p.smith, martin.panter stage: -> needs patch versions: +Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue33319> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36304] When using bz2 and lzma in mode 'wt', the BOM is not written
Martin Panter added the comment: I suspect this is caused by TextIOWrapper guessing if it is writing the start of a file versus in the middle, and being confused by “seekable” returning False. GzipFile implements some “seek” calls in write mode, but LZMAFile and BZ2File do not. Using this test class: class Writer(BufferedIOBase): def writable(self): return True def __init__(self, offset): self.offset = offset def seekable(self): result = self.offset is not None print('seekable ->', result) return result def tell(self): print('tell ->', self.offset) return self.offset def write(self, data): print('write', repr(data)) a BOM is inserted when “tell” returns zero: >>> t = io.TextIOWrapper(Writer(0), 'utf-16') seekable -> True tell -> 0 >>> t.write('HI'); t.flush() # Writes BOM 2 write b'\xff\xfeH\x00I\x00' and not when “tell” returns a positive number: >>> t = io.TextIOWrapper(Writer(1), 'utf-16') seekable -> True tell -> 1 >>> t.write('HI'); t.flush() # Omits BOM 2 write b'H\x00I\x00' However the “io” and “_pyio” behaviours differ when “seekable” returns False: >>> t = io.TextIOWrapper(Writer(None), 'utf-16') seekable -> False >>> t.write('HI'); t.flush() # io omits BOM 2 write b'H\x00I\x00' >>> t = _pyio.TextIOWrapper(Writer(None), 'utf-16') seekable -> False >>> t.write('HI'); t.flush() # _pyio writes BOM write b'\xff\xfeH\x00I\x00' 2 IMO the “_pyio” behaviour is more sensible: write a BOM because that’s what the UTF-16 codec produces. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue36304> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36294] `io.BufferedIOBase` returns `None`
Martin Panter added the comment: The general problem of non-blocking reads with BufferedIOBase is covered by Issue 13322. The documentation and implementations do not agree. I suggest to not rely on any particular behaviour reading BufferedIOBase objects in non-blocking mode. The problem of the concrete class BufferedReader (what “stdin.buffer” usually is) was also recently raised in Issue 35869. -- nosy: +martin.panter resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> buffered read() and write() does not raise BlockingIOError ___ Python tracker <https://bugs.python.org/issue36294> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36293] Nonblocking read sys.stdin raises error
Martin Panter added the comment: This is the same story as in Issue 35762. Both “sys.stdin” and “subprocess.Popen.stderr” (when universal_newlines=True is enabled) use the TextIOWrapper class, which I don’t think was implemented with non-blocking mode in mind. Issue 24560 is similar, but is about an older class “codecs.StreamReader”. -- nosy: +martin.panter superseder: -> subprocess.Popen with universal_newlines and nonblocking streams fails with "can't concat NoneType to bytes" ___ Python tracker <https://bugs.python.org/issue36293> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25476] close() behavior on non-blocking BufferedIO objects with sockets
Change by Martin Panter : -- stage: -> resolved status: pending -> closed ___ Python tracker <https://bugs.python.org/issue25476> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36246] csv.writer lineterminator affects csv escaping
Martin Panter added the comment: This is the result that I see: >>> output = StringIO() >>> csv.writer(output, lineterminator='\n').writerow(["Whoa!\rNewlines!"]) 16 >>> output.getvalue() 'Whoa!\rNewlines!\n' For comparison, this is the result with CRLF terminators (the default): >>> output = StringIO() >>> csv.writer(output, lineterminator='\r\n').writerow(["Whoa!\rNewlines!"]) 19 >>> output.getvalue() '"Whoa!\rNewlines!"\r\n' Is it a problem that the line terminator determines whether the CR is quoted or not? I believe the default policy is “excel”, which happens to use QUOTE_MINIMAL. This behaviour is documented: <https://docs.python.org/3.7/library/csv.html#csv.QUOTE_MINIMAL>. -- nosy: +martin.panter resolution: -> not a bug status: open -> pending ___ Python tracker <https://bugs.python.org/issue36246> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36226] multipart/related header causes false positive StartBoundaryNotFoundDefect and MultipartInvariantViolationDefect
Martin Panter added the comment: Probably the same as Issue 29353. I remember than enabling "headersonly" can create inconsistencies in the message object. But I don't remember the details. According to Issue 29991 (another duplicate), my patch for Issue 24363 might help. But I don't think I got much enthusiasm reviewing that (and I don't have time to spend on it now). -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue36226> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36172] csv module internal consistency
Martin Panter added the comment: The documentation <https://docs.python.org/dev/library/csv.html#module-contents> says you should “open the files with newline=''.” IMO this is an unfortunate quirk of the CSV module. Everything else that I know of in the Python built-in library either works with binary files, which typically do no newline translation in Python 3, or is fine with newline translation enabled in text mode. See also Issue 10954 about making the behaviour stricter. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue36172> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36161] Use thread-safe functions instead of unsafe ones (crypt, ttyname)
Martin Panter added the comment: In Issue 28503, “crypt_r” was added to Python 3.7 and 3.8+, and it looks like it is still there. Regarding error handling for “crypt”, it is not documented, but the Python function returns None on error. You would have to consider backwards compatibility to use OSError. Perhaps add a new parameter like “crypt(raise_error=True)”? -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue36161> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36050] Why does http.client.HTTPResponse._safe_read use MAXAMOUNT
Martin Panter added the comment: The 1 MiB limit was added for Issue 1296004; apparently some platforms were overallocating multiple buffers and running out of memory. I suspect the loop in "_safe_read" was inherited from Python 2, which has different kinds of file objects. The comments suggest it does partial reads. But the Python 3 code calls "socket.makefile" with "buffering" mode enabled by default. I agree it should be safe to read the total length in one go. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue36050> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36064] docs: urllib.request.Request not accepting iterables data type
Martin Panter added the comment: I agree the documentation is insufficient. It should have said if “data” is iterated, it must yield bytes-like objects. I agree it is unwise to yet more special cases for the uploaded data types. When Lye passed the dictionary of three keys and values, I suspect they weren’t expecting it to upload just the key names using one HTTP chunk for each key. See Issue 23740 about the mess of data types currently supported. -- ___ Python tracker <https://bugs.python.org/issue36064> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31162] urllib.request.urlopen CERTIFICATE_VERIFY_FAILED error
Change by Martin Panter : -- resolution: -> not a bug status: open -> pending title: urllib.request.urlopen error -> urllib.request.urlopen CERTIFICATE_VERIFY_FAILED error ___ Python tracker <https://bugs.python.org/issue31162> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22865] Document how to make pty.spawn not copy data
Martin Panter added the comment: I'm not sure it is wise for the Python documentation to suggest inserting null bytes in general. This seems more like an application-specific hack. There is nothing in Python that handles these null bytes specially, and I expect they will be seen if the child reads the terminal in raw mode, or if the parent's output is redirected to a file, sent over the network or a real serial link. -- ___ Python tracker <https://bugs.python.org/issue22865> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34785] pty.spawn -- auto-termination after child process is dead (a zombie)
Martin Panter added the comment: Suggest closing this assuming it is a duplicate, unless Jarry can give more information. -- resolution: -> duplicate status: open -> pending superseder: -> pty.spawn hangs on FreeBSD 9.3, 10.x ___ Python tracker <https://bugs.python.org/issue34785> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5038] urrlib2/httplib doesn't reset file position between requests
Martin Panter added the comment: For 3.7+ (where iterable objects are supported), I suggest: 1. Document the problem as a limitation of handlers like AbstractBasicAuthHandler, and consider raising an exception instead of trying to upload a file or iterable a second time. 2. Clarify the behaviour for different types of the “urllib.request” data parameter. I understand “file-like objects” means objects with a “read” attribute, and the “read” method is called in preference to iteration or treating the parameter as a “bytes” object. Despite the bug title, I don’t think the library should mess with the file position. Certainly not when making a single request. But it should already be possible for the caller to supply a custom iterable object that resets the file position: class FileReiterator: def __iter__(self): self.file.seek(0) while True: chunk = self.file.read(self.chunksize) yield chunk if len(chunk) < self.chunksize: break -- ___ Python tracker <https://bugs.python.org/issue5038> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22347] mimetypes.guess_type("//example.com") misinterprets host name as file name
Change by Martin Panter : -- dependencies: +Remove urllib.parse._splittype from mimetypes.guess_type ___ Python tracker <https://bugs.python.org/issue22347> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25862] TextIOWrapper assertion failure after read() and SEEK_CUR
Martin Panter added the comment: I haven’t confirmed, but it looks like the original change here broke bidirectional reading and writing with a single TextIOWrapper object; see Issue 35928. -- ___ Python tracker <https://bugs.python.org/issue25862> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35928] socket makefile read-write discards received data
Martin Panter added the comment: Looking over the changelog, my guess (untested) is this is caused by commit d6a283b3 for Issue 25862. That change looks like it drops the internal TextIOWrapper decoding buffer for each successful write. I don't have the right version of Python to test with, but I expect this to also be broken without using a socket: >>> f = TextIOWrapper(BufferedRWPair(BytesIO(b"Hello\nYou\n"), BytesIO())) >>> f.readline() 'Hello\n' >>> f.write(_) 6 >>> f.readline() # Does this now return EOF? 'You\n' -- keywords: +3.6regression nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue35928> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35906] Header Injection in urllib
Martin Panter added the comment: Maybe related to Victor's "Issue 1" described in Issue 32085. That is also a security bug about CRLF in the URL's path, but was opened before Issue 30500 was opened and the code changed, so I'm not sure if it is the same as this or not. Also there is Issue 13359, a proposal to automatically percent-encode invalid URLs. For a security fix, I'm not sure but it might be safer to raise an exception, rather than rewriting the invalid URL to a valid one. -- ___ Python tracker <https://bugs.python.org/issue35906> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35869] io.BufferReader.read() returns None
Martin Panter added the comment: This is covered by Issue 13322. There are a few other BufferedReader methods that contradict the documentation for non-blocking mode. A while ago I posted a patch to change the implementation to match the documentation, but nobody reviewed it or gave their opinion. These days I would prefer to just documentat the reality: the methods might raise an exception rather than returning None, or perhaps no particular behaviour at all is expected in general in the non-blocking case. But I don’t spend much time on Python now, so you might have to find someone else to move this forward. Regarding the entry for “BufferedReader.read”, it would make more sense to remove the last “if”: “if ‘size’ is not given . . ., until EOF, or the ‘read’ call would block”. But I don’t think even that is complete, because it should also say the read stops and returns short in the non-blocking case even when “size” is positive. -- assignee: -> docs@python components: +Documentation, IO nosy: +docs@python, martin.panter superseder: -> buffered read() and write() does not raise BlockingIOError ___ Python tracker <https://bugs.python.org/issue35869> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35870] readline() specification is unclear
Martin Panter added the comment: I agree that the documentation should be clearer about the first two points. Considering that the "input" function and by default the "str.splitlines" method both behave differently, I often had to re-learn this when I had less Python experience. The expected behaviour as I understand is the line terminator is included if it was read. It is not included if the size limit or EOF was reached first. The Python 2 documentation <https://docs.python.org/2/library/stdtypes.html#file.readline> is clear about both the newline being included and EOF behaviour. Regarding text files, if you mean the "TextIOWrapper.readline" method, I think it is reasonable to assume you get the translated line endings as specified by the constructor's "newline" argument: <https://docs.python.org/3/library/io.html#io.TextIOWrapper>. Newline='' and newline='\r\n' would keep the '\r\n' terminators, and newline=None would translate them to '\n'. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue35870> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35848] readinto is not a method on io.TextIOBase
Martin Panter added the comment: I think it would be more practical to fix the documentation (option 1). Do you have a use case for “TextIOBase.readinto” raising ValueError (something more concrete than someone having expectations)? -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue35848> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31456] SimpleCookie fails to parse any cookie if an entry has whitespace in the name
Martin Panter added the comment: The main cause of this behaviour is that whitespace (matching the ASCII RE “\s”) is treated as separation between cookie “morsels”. It looks like this has always been the behaviour, but I’m not sure it was intended. >>> print(BaseCookie('first=morsel second=morsel')) Set-Cookie: first=morsel Set-Cookie: second=morsel This could be a security problem, if an attacker managed to inject a CSRF token as the second “morsel”. This was mentioned in <https://translate.google.com/translate?u=https://habr.com/en/post/272187/>. IMO it would be better to not split off a second morsel. Either keep it as one long morsel value with spaces in, or skip over it to the next semicolon (;). The reason why the whole cookie string is lost is due to the behaviour of cookie morsels without equals signs: >>> BaseCookie('cookie=lost; ignore').items() dict_items([]) IMO it would be better to skip over these to the next semicolon as well. It looks like this is a regression in Python 3.5+ caused by Issue 22796. -- nosy: +martin.panter ___ Python tracker <https://bugs.python.org/issue31456> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com