[issue15533] subprocess.Popen(cwd) documentation: Posix vs Windows
Changes by Martin Panter <vadmium...@gmail.com>: -- components: +Windows stage: test needed -> needs patch title: subprocess.Popen(cwd) documentation -> subprocess.Popen(cwd) documentation: Posix vs Windows ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15533> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15451] PATH is not honored in subprocess.Popen in win32
Martin Panter added the comment: Perhaps this is a duplicate of Issue 8557 -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15451> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29387] Tabs vs spaces FAQ out of date
Martin Panter added the comment: Marco: I agree “Python reports an error” would have been simpler. That is what I meant to say. Anyway, perhaps we should put Python raises :exc:`IndentationError` if mixed tabs and spaces are causing problems in leading whitespace. In general, the exception seems to be IndentationError. TabError is a subclass, but is not raised in all circumstances. It seems the compiler assumes a particular tab model, so the exact exception depends on the amount of tabs and spaces: >>> exec("if True:\n" + " "*8 + "1\n" "\t2\n") Traceback (most recent call last): File "", line 1, in File "", line 3 2 ^ TabError: inconsistent use of tabs and spaces in indentation >>> exec("if True:\n" + " "*9 + "1\n" "\t2\n") Traceback (most recent call last): File "", line 1, in File "", line 3 2 ^ IndentationError: unindent does not match any outer indentation level -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29387> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20927] Different behaviour on Posix and Windows when using subprocess.Popen(..., cwd=path)
Changes by Martin Panter <vadmium...@gmail.com>: -- resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> subprocess.Popen(cwd) documentation ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20927> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13196] subprocess: undocumented if shell=True is necessary to find executable in Windows PATH
Martin Panter added the comment: It is hard to make sense of this without decoding your URLs, downloading the repository and finding the relevant commit. Anyway, what you have posted sounds like a duplicate of Issue 8557. -- nosy: +martin.panter resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> subprocess PATH semantics and portability ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13196> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18069] Subprocess searches special directories before PATH on Windows
Changes by Martin Panter <vadmium...@gmail.com>: -- title: Subprocess picks the wrong executable on Windows -> Subprocess searches special directories before PATH on Windows ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18069> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27867] various issues due to misuse of PySlice_GetIndicesEx
Martin Panter added the comment: Not a big deal, but the change produces compiler warnings with GCC 6.1.1: /home/proj/python/cpython/Objects/bytesobject.c: In function ‘bytes_subscript’: /home/proj/python/cpython/Objects/bytesobject.c:1701:13: warning: ‘slicelength’ may be used uninitialized in this function [-Wmaybe-uninitialized] for (cur = start, i = 0; i < slicelength; ^~~ /home/proj/python/cpython/Objects/listobject.c: In function ‘list_ass_subscript’: /home/proj/python/cpython/Objects/listobject.c:2602:13: warning: ‘slicelength’ may be used uninitialized in this function [-Wmaybe-uninitialized] for (i = 0; i < slicelength; i++) { ^~~ /home/proj/python/cpython/Objects/unicodeobject.c: In function ‘unicode_subscript’: /home/proj/python/cpython/Objects/unicodeobject.c:14013:16: warning: ‘slicelength’ may be used uninitialized in this function [-Wmaybe-uninitialized] result = PyUnicode_New(slicelength, max_char); ~~~^~ /media/disk/home/proj/python/cpython/Modules/_elementtree.c: In function ‘element_ass_subscr’: /media/disk/home/proj/python/cpython/Modules/_elementtree.c:1896:50: warning: ‘slicelen’ may be used uninitialized in this function [-Wmaybe-uninitialized] self->extra->children[i + newlen - slicelen] = self->extra->children[i]; ~~~^~ /media/disk/home/proj/python/cpython/Modules/_ctypes/_ctypes.c: In function ‘Array_subscript’: /media/disk/home/proj/python/cpython/Modules/_ctypes/_ctypes.c:4327:16: warning: ‘slicelen’ may be used uninitialized in this function [-Wmaybe-uninitialized] np = PyUnicode_FromWideChar(dest, slicelen); ~~~^~~~ My build used to be free of warnings. This warning is enabled via -Wall. The reason is probably that the new macro skips the slicelength assignment if PySlice_Unpack() fails. Workarounds could be to assign or initialize slicelength to zero (at the call sites or inside the macro), or to compile with -Wno-maybe-uninitialized. -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27867> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29300] Modify the _struct module to use FASTCALL and Argument Clinic
Martin Panter added the comment: FYI Victor, you can make non-C-contiguous buffers by slicing memoryview: >>> struct.unpack(">L", memoryview(b"1234")[::-1]) Traceback (most recent call last): File "", line 1, in BufferError: memoryview: underlying buffer is not C-contiguous Can also use the built-in _testbuffer module to create stranger buffers. -- resolution: -> fixed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29300> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29300] Modify the _struct module to use FASTCALL and Argument Clinic
Martin Panter added the comment: Shouldn’t the top-level unpack() parameter be called “buffer” like the other functions and methods, not “inputstr”? -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29300> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29169] update zlib to 1.2.11
Martin Panter added the comment: Misc/NEWS (and the commit message) say 1.2.10. Perhaps you meant 1.2.11? -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29169> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29070] Integration tests for pty.spawn on Linux and all other platforms
Martin Panter added the comment: Can you explain your broken pipe situation? Are you talking about a real-world EPIPE operating on a pseudoterminal, or just a result of using a Unix socket to emulate a PTY in the tests? Usually a broken pipe is an asynchronous condition. You cannot predict exactly when it will happen without knowing the state of the other end, OS implementation, buffering, etc. It does not seem appropriate to change the _copy() loop around unless there is an real bug. Regarding the buildbots, if I get this patch into a state that I am comfortable committing, the buildbots will are generally set to timeout in 15 or 20 minutes. See the “make buildbottest” commands in Makefile.pre.in, test.regrtest --timeout option, etc. You can also see which platforms have buildbots, and the state of them etc: <https://www.python.org/dev/buildbot/>. I left a bunch of comments in the code review. There is a lot of useful code in there, but also a lot of stuff that is hard to follow or that I want to clean up. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29070> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18842] Add float.is_finite is_nan is_infinite to match Decimal methods
Martin Panter added the comment: While I don’t have much opinion either way, here is a patch to remove the existing dead code should that be the eventual outcome. If the default implementations in the base class deferred to math.isfinite() etc, that may help with compatibility. -- versions: +Python 3.7 -Python 3.4 Added file: http://bugs.python.org/file46451/rm-finite.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18842> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29349] Update old Python 2 code in Docs/tools/extensions/patchlevel.py
Martin Panter added the comment: I pushed the simpler 2.6-compatible option. Keeping this open to check the buildbot is happy overnight. -- stage: needs patch -> resolved ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29349> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29387] Tabs vs spaces FAQ out of date
New submission from Martin Panter: The Windows FAQ <https://docs.python.org/release/3.5.2/faq/windows.html#how-do-i-keep-editors-from-inserting-tabs-into-my-python-source> mentions the “python -t” command-line option, but in Python 3 this option is undocumented (and I understand has no effect): /media/disk/home/proj/python/cpython/Doc/faq/windows.rst:303: WARNING: unknown option: -t Also, the reference to the tabnanny script is wrong. It exists as a module (Lib/tabnanny.py), not in Tools/scripts/. This aspect also applies to 2.7. -- assignee: docs@python components: Documentation, Windows files: tabnanny.patch keywords: patch messages: 286460 nosy: docs@python, martin.panter, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal stage: patch review status: open title: Tabs vs spaces FAQ out of date versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7 Added file: http://bugs.python.org/file46450/tabnanny.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29387> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29349] Update old Python 2 code in Docs/tools/extensions/patchlevel.py
Martin Panter added the comment: According to <https://bugs.python.org/issue17861#msg217417>, Ned says 2.6+ is already needed to build the Python 3.5 documentation, so maybe Sphinx uses that. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29349> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29349] Update old Python 2 code in Docs/tools/extensions/patchlevel.py
Martin Panter added the comment: Thanks Ned. Do you know what version of Python Sphinx uses (which runs patchlevel.py)? According to Issue 28039, David set up Python 2.7 so that “make touch” would work. But the log also uses a python2.5 command, and apparently Python 2.3 also installed on that buildbot. If we can rely on 2.6+, we just need to add “from __future__ import print_function”. Otherwise, we may need something like if sys.stderr is not None: sys.stderr.write(...) and also do something about that “with” statement. -- nosy: +db3l ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29349> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29384] Unused beos build scripts
Martin Panter added the comment: Thanks Senthil -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29384> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18842] Add float.is_finite is_nan is_infinite to match Decimal methods
Martin Panter added the comment: Of course, somehow I missed that -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18842> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29349] Update old Python 2 code in Docs/tools/extensions/patchlevel.py
Martin Panter added the comment: I think the general rule is to clean up code if you are doing something else in nearby code, but don’t go out of your way with unnecessary cleanups to arbitrary code. Otherwise it adds too much noise to the repository history, review process, risks adding bugs, etc, for little gain. Anyway, thanks for the patch! -- resolution: -> fixed stage: commit review -> resolved status: open -> closed versions: -Python 3.4 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29349> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20185] Derby #17: Convert 49 sites to Argument Clinic across 13 files
Martin Panter added the comment: longobject_v5 looks good to me -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20185> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20180] Derby #11: Convert 50 sites to Argument Clinic across 9 files
Martin Panter added the comment: For str.format_map(mapping), yes the parsing happens in Objects/stringlib/unicode_format.h, but I don’t see that as a big problem. Moving this back to “needs patch”, assuming it is okay to convert format_map(). Other than from that, there are just tricky things left like the str() constructor, str.format(*args, **kwargs) (see Issue 20291), and the shared code in Objects/stringlib/find.h and Objects/stringlib/transmogrify.h. I don’t know what to do about those. -- nosy: +martin.panter stage: commit review -> needs patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20180> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18842] Add float.is_finite is_nan is_infinite to match Decimal methods
Martin Panter added the comment: FWIW, here is an attempt to add Argument Clinic to the Objects/floatobject.c and Objects/longobject.c implementations: https://bugs.python.org/file33943/issue20185_conglomerate_v4.diff https://bugs.python.org/file33989/clinic_longobject_v3.patch If the methods are rejected, the dead code should be removed to avoid wasting people’s time. Why do you name the methods is_finite() etc with underscores, when the existing methods math.isfinite() etc do not have underscores? Seems it would add unnecessary confusion. -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18842> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23980] Documentation for format units starting with 'e' is inconsistent
Martin Panter added the comment: The O! and O& units are in a similar situation. They just use a different font and descriptive name, rather than a specific type: ``O!`` (object) [*typeobject*, PyObject \*] ``O&`` (object) [*converter*, *anything*] Following this lead, you could write: ``es`` (:class:`str`) [*encoding*, char \*buffer] ``et`` (. . .) [*encoding*, char \*buffer] ``es#`` (:class:`str`) [*encoding*, char \*buffer, int buffer_length] ``et#`` (. . .) [*encoding*, char \*buffer, int buffer_length] The text description should explain what *encoding* is, but it appears it may already do that well enough. -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23980> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29384] Unused beos build scripts
New submission from Martin Panter: Modules/ld_so_beos and Modules/ar_beos are no longer used since Be OS support was dropped from the configure script for Python 3: https://hg.python.org/cpython/diff/a5e984eda45a/configure.in I propose to also remove the scripts. -- components: Build files: beos-scripts.patch keywords: patch messages: 286426 nosy: martin.panter priority: normal severity: normal stage: patch review status: open title: Unused beos build scripts type: enhancement versions: Python 3.7 Added file: http://bugs.python.org/file46447/beos-scripts.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29384> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3991] urllib.request.urlopen does not handle non-ASCII characters
Martin Panter added the comment: I’m not really an expert on non-ASCII URLs / IRIs. Maybe it is obvious to other people that this is a good general implementation, but for me to thoroughly review it I would need time to research the relevant RFCs, other implementations, suitability for the URL schemes listed at <https://docs.python.org/dev/library/urllib.parse.html>, security implications, etc. One problem problem with using urlunsplit() is it would strip empty URL components, e.g. quote_iri("http://example/file#;) -> "http://example/file;. See Issue 22852. This is highlighted by the file:///[. . .] → file:/[. . .] test case. FYI Martin Panter and vadmium are both just me, no need to get too excited. :) I just updated my settings for Rietveld (code review), so hopefully that is more obvious now. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue3991> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20664] _findLib_crle and _get_soname broken on latest SunOS 5.11
Martin Panter added the comment: There is an Open Indiana buildbot <http://buildbot.python.org/all/buildslaves/cea-indiana-x86>, that was passing test_ctypes (until the buildbot went offline a few weeks ago). Would it be possible to include a regression test case? Also, in <https://bugs.python.org/issue23287#msg247067>, John said that /usr/ccs/bin is a symbolic link to /usr/bin/, so I wonder if this really is a problem. Perhaps the symlink does not exist on some OS versions? Regarding an environment variable for library searching, perhaps that is related to Issue 9998 (searched LD_LIBRARY_PATH env. var. on Linux). See also Issue 19317, discussing RPATH fom sys.executable. -- nosy: +martin.panter stage: -> patch review versions: +Python 3.6, Python 3.7 -Python 3.1, Python 3.2, Python 3.3, Python 3.4 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20664> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23287] ctypes.util.find_library needlessly call crle on Solaris
Martin Panter added the comment: Do you have an opinion of the proposal Shawn? Judging by John’s “[the constant] is what the system provides, though users may customize as needed”, it sounds like the patch is more than a bug fix. Will it also mean find_library() will no longer search customized library directories? I’m not familiar with Solaris, but it seems this may not be intended or desired. Why is this bug marked as “resource usage”? -- nosy: +martin.panter stage: -> patch review ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23287> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29379] Custom handlers not used when passing "context" argument to urllib2.urlopen()
Martin Panter added the comment: I presume this is the same as in Issue 18543 (and a few other duplicates). Let me know if I got it wrong. IMO there is no easy fix. The best solution may be to just document the behaviour as a limitation of the API, and design a new/improved API for the future (Py 3.7+) that handles these cases. -- nosy: +martin.panter resolution: -> duplicate status: open -> closed superseder: -> urllib.parse.urlopen shouldn't ignore installed opener when called with any SSL argument ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29379> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15769] urllib.request.urlopen with cafile or capath set overrides any previous Handlers
Martin Panter added the comment: Nothing has been fixed; I don’t see any evidence that this is “out of date”. Here is a more complete test: import urllib.request opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor()) urllib.request.install_opener(opener) request = 'https://httpbin.org/cookies/set?name=value' # Download certifiate chain for https://httpbin.org/ into cacert.pem (I used Firefox) sock = urllib.request.urlopen(request, cafile = 'cacert.pem') sock.read() # b'{\n "cookies": {}\n}\n' (No cookies!) sock.close() sock = urllib.request.urlopen(request) # Default SSL settings sock.read() # b'{\n "cookies": {\n"name": "value"\n }\n}\n' I’m not comfortable with applying a patch that “doesn’t mangle [the global state] too much”. Anyway, this is the same as Issue 18543, which has slightly more recent discussion. -- nosy: +martin.panter resolution: out of date -> duplicate status: pending -> closed superseder: -> urllib.parse.urlopen shouldn't ignore installed opener when called with any SSL argument ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15769> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29375] httplib: wrong Host header when connecting to IPv6 link-local address
Martin Panter added the comment: More closely related: Issue 23448, about the same thing with urllib, which adds the Host value itself. Any solution should be shared between both modules. -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29375> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29374] Doc bug: signal.sigwait and signal.sigtimedwait do not work outside the Main thread
Martin Panter added the comment: This works for me on Linux: >>> signal.pthread_sigmask(signal.SIG_BLOCK, {signal.SIGUSR1}) set() >>> import threading >>> t = threading.Thread(target=sigwait) >>> t.start() Send me a signal, my PID is 24197 >>> os.kill(os.getpid(), signal.SIGUSR1) Got the signal: 10 >>> t.join() Posix <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigwait.html> only defines sigwait() if the signals are already blocked. Two reasons behind this come to mind: 1. There would be a race where the signal handler may be called first (or the signal may be ignored) at the OS level, and the sigwait() function will miss the signal and block. 2. If the signal is handled in the context of another thread that isn’t using sigwait(), it may be consumed (handled or ignored) in the context of the other thread, with no effect on your sigwait() call. This detail of blocking the signal seems to be a common error, so maybe the Python documentation could help point it out. (Issue 25868 comes to mind; there is a test case that IMO should block a signal before waiting for it.) -- nosy: +martin.panter versions: -Python 3.4 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29374> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29375] httplib: wrong Host header when connecting to IPv6 link-local address
Changes by Martin Panter <vadmium...@gmail.com>: -- components: +Library (Lib) stage: -> needs patch versions: +Python 3.6, Python 3.7 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29375> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18235] _sysconfigdata.py wrong on AIX installations
Martin Panter added the comment: Sorry I meant Issue 10656. I recently committed a fix regarding out-of-tree builds and ld_so_aix, and it sounds like you were thinking of reverting that. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18235> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18235] _sysconfigdata.py wrong on AIX installations
Martin Panter added the comment: I don’t run AIX, but my understanding is there are three distinct branches (2.7, 3.5, and 3.6+). Some of the following is guessed, so please correct me if I am wrong: Python 2.7: _sysconfigdata.py incorrectly created with LDSHARED = Modules/ld_so_aix. Result: Installed distutils fails (unless you’re in the build tree). Fix: Apply David’s issue18235.patch + Michael H’s msg219888 fix. Python 3.5: David’s issue18235.patch already applied. _sysconfigdata.py incorrectly created with BLDSHARED = $(LIBPL)/ld_so_aix, i.e. the installed location. Distutils does not refer to _sysconfigdata.py. Result: Distutils unaffected, but running from the build tree, sysconfig.get_config_var("LDSHARED") would incorrectly use the installed location. Fix: Apply Michael H’s msg219888. Python 3.6+: Distutils does use _sysconfigdata*.py, thanks to revision 3fa8aebed636. Result: Distutils shouldn’t work unless Python is already installed. Since the 3.6 and 3.x buildbots pass test_distutils, does that mean that both those versions of Python are already installed? Fix: Should also be fixed by merging msg219888 from 3.5. Marc-Andre, regarding configure.ac and absolute vs relative paths, I suggest you open a separate bug. That is an orthogonal issue, and this bug is already too complicated. But also keep in mind Issue 18235. You want the build tree, not the source tree. Also, if you mean to drop the assignment in sysconfig, I think that will break in-tree usage of sysconfig (3.5+) and distutils (3.6+), unless Python happens to also be installed. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18235> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29273] test___all__ alters utf8 locale setting
Changes by Martin Panter <vadmium...@gmail.com>: -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29273> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24363] httplib fails to handle semivalid HTTP headers
Martin Panter added the comment: Just a minor update with an extra get_payload() test I missed before -- versions: +Python 3.7 Added file: http://bugs.python.org/file46400/policy-flag.v2.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24363> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28556] typing.py upgrades
Martin Panter added the comment: ERROR: test_annotation_usage_with_methods (test.test_typing.NamedTupleTests) -- Traceback (most recent call last): File "/home/proj/python/cpython/Lib/test/test_typing.py", line 2058, in test_annotation_usage_with_methods self.assertEquals(XMeth(1).double(), 2) File "/home/proj/python/cpython/Lib/unittest/case.py", line 1311, in deprecated_func DeprecationWarning, 2) DeprecationWarning: Please use assertEqual instead. -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28556> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29349] Update old Python 2 code in Docs/tools/extensions/patchlevel.py
Martin Panter added the comment: Is it okay to only fix this in 3.5+? 3.4 only gets security fixes now. Either way, the “with” statement changes is not a bug fix and should only go into 3.7. -- nosy: +martin.panter stage: -> commit review ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29349> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12067] Doc: remove errors about mixed-type comparisons.
Changes by Martin Panter <vadmium...@gmail.com>: Added file: http://bugs.python.org/file46399/expressions-py3.7_v17.diff ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12067> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12067] Doc: remove errors about mixed-type comparisons.
Martin Panter added the comment: Updated patch for 2.7, which I plan to commit soon. Corresponding Py 3 patch coming soon. -- Added file: http://bugs.python.org/file46398/expressions-py2.7_v17.diff ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12067> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21272] use _sysconfigdata to itinialize distutils.sysconfig
Changes by Martin Panter <vadmium...@gmail.com>: -- versions: +Python 3.6 -Python 3.5 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21272> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29353] Incorrect handling of HTTP response with "Content-Type: message/rfc822" header
Martin Panter added the comment: There is an inconsistency when parsing with headersonly=True. According to the documentation, get_payload() with message/rfc822 should should return a list of Message objects, not a string. But using headersonly=True produces a non-multipart Message object: >>> m = Parser().parsestr("Content-Type: message/rfc822\r\n\r\n", >>> headersonly=True) >>> m.get_content_type() 'message/rfc822' >>> m.is_multipart() # Doc says True False >>> m.get_payload() # Doc says list of Message objects '' Related to this, setting headersonly=True can also cause a internal inconsistency. Maybe this is why it was called a “hack”: >>> Parser().parsestr("Content-Type: message/delivery-status\r\nInvalid >>> line\r\n\r\n", headersonly=True).as_string() Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.5/email/message.py", line 159, in as_string g.flatten(self, unixfrom=unixfrom) File "/usr/lib/python3.5/email/generator.py", line 115, in flatten self._write(msg) File "/usr/lib/python3.5/email/generator.py", line 181, in _write self._dispatch(msg) File "/usr/lib/python3.5/email/generator.py", line 214, in _dispatch meth(msg) File "/usr/lib/python3.5/email/generator.py", line 331, in _handle_message_delivery_status g.flatten(part, unixfrom=False, linesep=self._NL) File "/usr/lib/python3.5/email/generator.py", line 106, in flatten old_msg_policy = msg.policy AttributeError: 'str' object has no attribute 'policy' I think it may be best only change get_payload() to return a string in the next Python version (3.7), with appropriate documentation updates. For existing Python versions, perhaps urllib3 could check if the list returned by get_payload() only has trivial empty Message objects (no header fields and only empty payloads themselves). If we agree that only a feature change for 3.7 is appropriate, there are other problems with the current parsing of HTTP headers that could also be looked at: * Only a blank line should end a header section (Issue 24363, Issue 26686) * “From” line should be a defect * Use “email” package’s HTTP parsing policy * Don’t assume Latin-1 encoding (Issue 27716) * Avoid double-handling (header lines are parsed in http.client, then joined together and parsed again in email.feedparser) -- components: +email nosy: +barry, martin.panter versions: -Python 3.3, Python 3.4 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29353> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29152] unittest subTest does not call addFailure
Martin Panter added the comment: It is not obvious what the effect of not calling addFailure() is, but perhaps this is related to Issue 25894? Failure and error statuses are not immediately reported from subtests. -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29152> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18235] _sysconfigdata.py wrong on AIX installations
Martin Panter added the comment: If the assignment is completely removed, won’t this break the test when run from the source or build tree (as opposed to when installed)? Or at least make the situation worse: the AIX buildbot is already failing test_distutils, but at least it is looking for Modules/ld_so_aix locally rather than in the yet-to-be-installed location. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18235> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29343] sock.close() raises OSError EBADF when socket's fd is closed
Martin Panter added the comment: I added this behaviour in 3.6 on purpose via Issue 26685. The change also impacted Yury (see the original bug thread), but if I understood correctly, he eventually decided that it highlighted a problem in asyncio or his code (though the resulting asyncio pull request seems to have stalled). Before he came to that decision, I did suggest temporarily using DeprecationWarning instead of an exception: <https://bugs.python.org/issue26685#msg278949>. IMO passing a freed file descriptor to close() is asking for trouble. The descriptor could be recycled, by another thread, or even internally by a function call in the same thread. Another problem is if you don’t end up calling socket.close(), the garbage collector may arbitrarily close an FD in use in the future. Your example code was not realistic, but I would say the solution is either call socket.detach() rather than socket.fileno(), or don’t call os.close() and just call socket.close(). I think that Linux man page is talking more about asynchronous errors from a previous write call. Even if we tolerated other errors from close(), I would still like to treat EBADF as a real error. -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29343> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15997] NotImplemented needs to be documented
Changes by Martin Panter <vadmium...@gmail.com>: -- dependencies: +Clarify the behavior of __eq__() returning NotImplemented ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15997> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28785] Clarify the behavior of __eq__() returning NotImplemented
Changes by Martin Panter <vadmium...@gmail.com>: -- title: Clarify the behavior of NotImplemented -> Clarify the behavior of __eq__() returning NotImplemented ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28785> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26273] Expose TCP_CONGESTION and TCP_USER_TIMEOUT to the socket module
Martin Panter added the comment: Patch looks good to me. BTW in Issue 27409 I proposed a patch listing more of these. -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26273> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1732367] Document the constants in the socket module
Changes by Martin Panter <vadmium...@gmail.com>: -- dependencies: +Document socket.SOL_SOCKET ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue1732367> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29311] Argument Clinic: convert dict methods
Martin Panter added the comment: Patch looks good, apart from one little thing (see review) -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29311> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20185] Derby #17: Convert 49 sites to Argument Clinic across 13 files
Martin Panter added the comment: Will keep this in mind, but my time is rather limited, so I may not get to it (and I wouldn’t want to discourage other people from working on it) -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20185> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29182] Remove the warning in urllib docs that it doesn't do certificate validate by default.
Martin Panter added the comment: The warning for urllib2.urlopen() was removed in revision 1882157b298a. However, a couple other warnings were converted to “Changed in version 2.7.9” in revision fb83916c3ea1, which seems safer to me. Removing documentation almost seems like a step backwards. The usual approach for new features is to document the new behaviour, and when it changed. This has also been done for the “context” etc parameters added in a bug fix release. So I suggest to document that the certificate is verified since 2.7.9, but not beforehand. -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29182> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12067] Doc: remove errors about mixed-type comparisons.
Martin Panter added the comment: Here is a port of the documentation to Python 2. Main differences: * Default rules for order comparisons are different * Not all kinds of objects inherit from object() * str(), unicode() compatibility * xrange() only seems to have default comparability * NAN, “binary sequences” and sets not listed -- Added file: http://bugs.python.org/file46372/expressions-py2.7.diff ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12067> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29330] __slots__ needs documentation
Martin Panter added the comment: Have you seen <https://docs.python.org/2.7/reference/datamodel.html#slots>? There is also <https://docs.python.org/2.7/glossary.html#term-slots>. -- assignee: -> docs@python components: +Documentation nosy: +docs@python, martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29330> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29323] Wrong documentation (Library) for unicode and str comparison
Martin Panter added the comment: If you read the whole paragraph carefully, I don't think it is too misleading. "In particular, tuples and lists . . ." suggests the author was just trying to say that a tuple never compares equal to a list. Maybe we just need to make that more obvious? However there are other problems in this part of the reference about comparing different types. See Issue 22000, about the earlier section on Comparisons of built-in types. -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29323> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29311] Argument Clinic: convert dict methods
Martin Panter added the comment: D.get(key[, default]) -> D[key] if key in D, else default. There is no big problem with that. D is defined at the start. The only thing I would have suggested is avoid using square brackets to mean two things in the one expression. Since it is no longer the signature, calling with both parameters should be okay: ''' get($self, key, default=None, /) -- D.get(key, default) -> D[key] if key in D, else default. ''' However the other method no longer defines D: ''' setdefault($self, key, default=None, /) -- D.get(key,default), also set D[key]=default if key not in D. ''' You could restore the initial text as “D.setdefault(key,default) ->”, or maybe rewrite it like “Like get(), but also insert the default value if it is missing.” -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29311> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29321] Wrong documentation (Language Ref) for unicode and str comparison
Martin Panter added the comment: The Python 3 version of this was rewritten in Issue 12067. It would be good to port the new text to the Python 2 version, although that is not straightforward because of various differences between Python 2 and 3. That doesn’t rule out making smaller more specific edits in the mean time. However your proposal still seems misleading to only mention str and unicode as special cases. It does not allow for str vs bytearray, set vs frozenset, or custom classes/types implementing their own __eq__() etc methods. -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29321> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12067] Doc: remove errors about mixed-type comparisons.
Changes by Martin Panter <vadmium...@gmail.com>: -- dependencies: +Wrong documentation (Language Ref) for unicode and str comparison ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12067> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29274] Change “tests cases” → “test cases”
Martin Panter added the comment: Thanks for the feedback -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29274> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29305] encoding to ascii in http/client.py
Martin Panter added the comment: In general, HTTP URLs are supposed to be ASCII only. Newer protocols (e.g. RTSP which is based on HTTP) specifically allow UTF-8 encoding. But it would be wrong for Python’s HTTP library to assume UTF-8 is wanted everywhere. Especially in a domain name (e.g. in the full-URL request to a proxy), which should not be UTF-8 encoded. I suggest to work on handling IRIs (<https://tools.ietf.org/html/rfc3987>, basically Unicode URLs) in higher-level places like “urllib”. See Issue 3991. -- nosy: +martin.panter resolution: -> rejected status: open -> closed superseder: -> urllib.request.urlopen does not handle non-ASCII characters title: encoding to ascii in client.py -> encoding to ascii in http/client.py type: compile error -> enhancement ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29305> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3991] urllib.request.urlopen does not handle non-ASCII characters
Martin Panter added the comment: Issue 9679: Focusses on encoding just the DNS name Issue 20559: Maybe a duplicate, or opportunity for better documentation or error message as a bug fix? Andreas’s patch just proposes a new function called quote_uri(). It would need documentation. We already have a quote() and quote_plus() function. Since it sounds like this is for IRIs (https://tools.ietf.org/html/rfc3987), would it be more appropriate to call it quote_iri()? See revision cb09fdef19f5, especially the quote(safe=...) parameter, for how I avoided the double encoding problem. -- dependencies: +unicode DNS names in urllib, urlopen nosy: +martin.panter stage: test needed -> patch review versions: +Python 3.7 -Python 3.2, Python 3.3, Python 3.4 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue3991> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20559] urllib/http fail to sanitize a non-ascii url
Martin Panter added the comment: See also Issue 3991 with proposals for handling non-ASCII as new features. -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20559> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29290] argparse breaks long lines on NO-BREAK SPACE
Martin Panter added the comment: Maybe a duplicate of Issue 16623 -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29290> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27659] Prohibit implicit C function declarations
Martin Panter added the comment: I would say it is more important to fit in with the surrounding style than mindlessly follow PEP 7. IMO the indentation in the configure script is a mess, but if we fix it up, it should probably be done separately to adding this extra flag. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27659> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13886] readline-related test_builtin failure
Martin Panter added the comment: V3 of my patch skips the Readline tests in cases involving non-ASCII bytes when the locale seen by Readline would be ASCII. Readline may translate the non-ASCII bytes to escape sequences, and treat them as special Meta (Alt) key combinations. This behaviour depends on Readline configuration (“set convert-meta off” in /etc/inputrc in my case). It also includes a potential workaround for Android, depending on the resolution of Issue 28997. -- Added file: http://bugs.python.org/file46296/input-readline.v3.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13886> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28997] test_readline.test_nonascii fails on Android
Martin Panter added the comment: So the problem seems to be that Python assumes Readline’s encoding is UTF-8, but Readline actually uses ASCII (depending on locale variables). The code at the start of the test is supposed to catch when add_history() calls PyUnicode_EncodeLocale() and fails. I don’t understand the details of UTF-8 vs locale on Android, but maybe we could adjust the encode() and decode() implementations in Modules/readline.c, to account for the Readline library’s idea of the locale encoding. Or maybe we could adjust the temporary setlocale() calls in Modules/readline.c. If you are happy to declare the Readline library is broken on Android, I now think I would prefer to skip the test based on support.is_android, rather than the previous patches. Otherwise, we risk masking genuine test failures on other platforms. Something like: @unittest.skipIf(is_android, "Gnu Readline disagrees about the locale encoding on Android") def test_nonascii(self): try: readline.add_history("\xEB\xEF") ... When you run “LANG= bash”, it is only Bash and Readline that gets the C locale; the terminal is unchanged. I presume the terminal inputs é as two UTF-8 bytes, but Readline with the C locale is not aware of UTF-8, and assumes the two bytes are two separate characters. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28997> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29274] Change “tests cases” → “test cases”
New submission from Martin Panter: The “unittest” documentation has “tests cases” written a few times. This doesn’t seem right to me, but I thought I should get a second opinion in case I missed something. -- assignee: docs@python components: Documentation files: tests-cases.patch keywords: patch messages: 285468 nosy: docs@python, martin.panter priority: normal severity: normal stage: patch review status: open title: Change “tests cases” → “test cases” versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7 Added file: http://bugs.python.org/file46288/tests-cases.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29274> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29273] test___all__ alters utf8 locale setting
New submission from Martin Panter: On a Linux computer I have LANG=en_US.utf8 set. Python 3 initializes the locale with this setting (see revision 43e32b2b4004): >>> locale.setlocale(locale.LC_CTYPE) # Get setting initialized by Python 'en_US.utf8' In Lib/test/test___all__.py, there is a special case to restore the locale after loading the “readline” module (last changed in revision 37ed6eed0595). It does this by calling getlocale() and later setlocale(). However the getlocale() call translates the setting to UTF-8 in uppercase with a dash, and setlocale() keeps it that way: >>> locale.getlocale(locale.LC_CTYPE) ('en_US', 'UTF-8') >>> locale.setlocale(locale.LC_CTYPE, _) 'en_US.UTF-8' This means that the test framework may complain: Warning -- locale was modified by test___all__ One subtlety is that I only see the warning when the “tkinter” module is unavailable. Otherwise, the test imports Lib/idlelib/iomenu.py, which calls setlocale(locale.LC_CTYPE, "") and restores the original “utf8” spelling. The easiest fix would be to use setlocale(locale.LC_CTYPE) instead of getlocale() in test___all__. However I think it may be safe to remove this code entirely. The original version of the it was added by Guido in revision ba522c74a931 (year 2002). Three hours later is revision c7d5801bbae8, where Guido changed the “readline” module to restore the locale after Readline library initialization. Since the module is fixed, I don’t think we need the test workaround, and I propose to remove it in Python 3, where it causes the above conflict. -- components: Tests files: readline-getlocale.patch keywords: patch messages: 285467 nosy: martin.panter priority: normal severity: normal stage: patch review status: open title: test___all__ alters utf8 locale setting type: behavior versions: Python 3.5, Python 3.6, Python 3.7 Added file: http://bugs.python.org/file46287/readline-getlocale.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29273> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29062] hashlib documentation link error
Martin Panter added the comment: Looks like Doc/tools/susp-ignored.csv needs updating: $ make -C Doc/ suspicious [. . .] writing output... [ 49%] library/hashlib WARNING: [library/hashlib:502] ":vatrogasac" found in ">>> cookie = b'user:vatrogasac'" WARNING: [library/hashlib:502] ":vatrogasac" found in "user:vatrogasac,349cf904533767ed2d755279a8df84d0" WARNING: [library/hashlib:502] ":policajac" found in ">>> compare_digest(b'user:policajac', sig)" WARNING: [library/hashlib:646] ":LEAF" found in "... h00 = blake2b(buf[0:LEAF_SIZE], fanout=FANOUT, depth=DEPTH," [. . .] WARNING: Found 4/327 unused rules: library/hashlib-blake2,,:vatrogasac,>>> cookie = b'user:vatrogasac' library/hashlib-blake2,,:vatrogasac,user:vatrogasac,349cf904533767ed2d755279a8df84d0 library/hashlib-blake2,,:policajac,>>> compare_digest(b'user:policajac', sig) library/hashlib-blake2,,:LEAF,h00 = blake2b(buf[0:LEAF_SIZE], fanout=FANOUT, depth=DEPTH, build finished with problems, 7 warnings. make[1]: *** [build] Error 1 make[1]: Leaving directory `/media/disk/home/proj/python/cpython/Doc' Suspicious check complete; look for any errors in the above output or in build/suspicious/suspicious.csv. If all issues are false positives, append that file to tools/susp-ignored.csv. make: *** [suspicious] Error 1 -- status: closed -> open ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29062> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16189] config/ld_so_aix not found: old dir name
Changes by Martin Panter <vadmium...@gmail.com>: -- title: ld_so_aix not found -> config/ld_so_aix not found: old dir name ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue16189> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18235] _sysconfigdata.py wrong on AIX installations
Martin Panter added the comment: So are you saying you tried patching Python 2 and/or 3, but did not see any relevant change at all? -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18235> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25825] AIX shared library extension modules installation broken: wrong dir names
Changes by Martin Panter <vadmium...@gmail.com>: -- title: AIX shared library extension modules installation broken -> AIX shared library extension modules installation broken: wrong dir names ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25825> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29251] Class __dict__ is only a mapping proxy
New submission from Martin Panter: The __dict__ attribute of class objects is documented as being a (standard) dictionary, but implemented with a proxy object. I propose to clarify the documentation in “Custom classes” under <https://docs.python.org/3.5/reference/datamodel.html#the-standard-type-hierarchy>, and in <https://docs.python.org/3.5/library/functions.html#type>. I believe my changes are also applicable to Python 2, as long as I point out the proxy is specific to “new-style” classes. -- assignee: docs@python components: Documentation files: class-dict.patch keywords: patch messages: 285313 nosy: docs@python, martin.panter priority: normal severity: normal stage: patch review status: open title: Class __dict__ is only a mapping proxy type: behavior versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7 Added file: http://bugs.python.org/file46268/class-dict.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29251> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17824] pty.spawn handles errors improperly
Martin Panter added the comment: The patch for Issue 26228 proposes an improvement to the situation, although it is not perfect and does not include a test. I wonder if it is possible to replace fork() and execlp() with a subprocess.Popen invokation, at least in a new Python release? -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17824> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29239] Fix wrong issue number in what's new entry
Martin Panter added the comment: Thanks Jim -- nosy: +martin.panter resolution: -> fixed stage: -> resolved status: open -> closed versions: +Python 3.7 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29239> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15216] Support setting the encoding on a text stream after creation
Martin Panter added the comment: Inada, I think you messed up the positioning of bits of the patch. E.g. there are now test methods declared inside a helper function (rather than a test class). Since it seems other people are in favour of this API, I would like to expand it a bit to cover two uses cases (see set_encoding-newline.patch): * change the error handler without affecting the main character encoding * set the newline encoding (also suggested by Serhiy) Regarding Serhiy’s other suggestion about buffering parameters, perhaps TextIOWrapper.line_buffering could become a writable attribute instead, and the class could grow a similar write_through attribute. I don’t think these affect encoding or decoding, so they could be treated independently. The algorithm for rewinding unread data is complicated and can fail. What is the advantage of using it? What is the use case for reading from a stream and then changing the encoding, without a guarantee that it will work? Even if it is enhanced to never “fail”, it will still have strange behaviour, such as data loss when a decoder is fed a single byte and produces multiple characters (e.g. CR newline, backslashreplace, UTF-7). One step in the right direction IMO would be to only support calling set_encoding() when no extra read data has been buffered (or to explicitly say that any buffered data is silently dropped). So there is no support for changing the encoding halfway through a disk file, but it may be appropriate if you can regulate the bytes being read, e.g. from a terminal (user input), pipe, socket, etc. But I would be happy enough without set_encoding(), and with something like my rewrap() function at the bottom of <https://github.com/vadmium/data/blob/master/data.py#L526>. It returns a fresh TextIOWrapper, but when you exit the context manager you can continue to reuse the old stream with the old settings. -- Added file: http://bugs.python.org/file46255/set_encoding-newline.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15216> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15657] Error in Python 3 docs for PyMethodDef
Martin Panter added the comment: . The documentation did not get merged properly into 3.6+. And even in 3.5, under METH_KEYWORDS, I propose to change “The flag is typically combined with METH_VARARGS” to “The flag must be combined . . .”. The remaining issue15657_36.diff patch looks out of date. There is a _PyCFunction_FastCallDict() function that appears to also need adjusting. But instead of changing the value of METH_KEYWORDS, wouldn’t it be safer to just accept METH_KEYWORDS (= 2) on its own as a valid value? This is what Python 2 does. Essentially, revert the first hunk of https://hg.python.org/cpython/diff/b7bfa780a882/Objects/methodobject.c but without METH_OLDARGS, whose value was zero anyway. BTW, the statement did not need to be removed in Python 2, but IMO it’s fine now without the statment. The statement was added in revision 1564c6839e6b. -- nosy: +martin.panter versions: +Python 3.7 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15657> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29145] failing overflow checks in replace_*
Martin Panter added the comment: Both fixes (join and replace) look good to me. However I don’t think it is necessary to change the exception message in 3.5 or 3.6. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29145> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29145] failing overflow checks in replace_*
Martin Panter added the comment: FTR I thought the consensus was not to backport these fixes unless there was a demonstrated problem: <https://bugs.python.org/issue1621#msg144499>, though personally, I would be in favour of backporting in many cases. Regarding str.join() in unicode.c, see also my unicode.patch in that bug. I included a test case that works on 32-bit platforms, which you may use. (From memory, you probably need to disable -fwrapv and maybe use -ftrapv or the undefined behaviour sanitizer to make the test fail.) -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29145> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1621] Do not assume signed integer overflow behavior
Changes by Martin Panter <vadmium...@gmail.com>: -- dependencies: +failing overflow checks in replace_* ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue1621> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29208] BlockingIOError during system startup
Martin Panter added the comment: David you are right, thanks. Dustin: the exact patch you want is revision 0a55e039d25f. -- resolution: -> duplicate status: open -> closed superseder: -> Python 3.6 on Windows doesn't seed Random() well enough ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29208> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29208] BlockingIOError during system startup
Martin Panter added the comment: It looks like the logic for handling an error seeding from urandom is reversed: <https://hg.python.org/cpython/rev/45fc0c83ed42#l6.66>. Random_seed_urandom() actually returns -1 if is an exception set, and 0 if it was successful. The result would be a normal working urandom setup ignores urandom and seeds from the time and PID. Not a big deal, since the old code always seeded from a (lower resolution) time anyway. But if urandom failed, we get the SystemError. The fix should be simple, in Modules/_randommodule.c change the random_seed() function to read if (arg == NULL || arg == Py_None) { if (random_seed_urandom(self) < 0) { // was >= 0! PyErr_Clear(); /* Reading system entropy failed, fall back on the worst entropy: use the current time and process identifier. */ random_seed_time_pid(self); } Py_RETURN_NONE; } -- keywords: +3.6regression nosy: +haypo, martin.panter type: -> behavior ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29208> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29204] Add code deprecations in ElementTree
Martin Panter added the comment: Isn’t cElementTree useful and recommended in 2.7? It would be awkward to deprecate it in Python 3. But I guess the other cases should be okay to deprecate in 3.7. -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29204> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28997] test_readline.test_nonascii fails on Android
Martin Panter added the comment: . Thanks for the explanation. It sounds like the Readline library assumes an ASCII-only locale and sets its “convert-meta” variable to “on”. But Python assumes UTF-8 and inputs b"\xC3\xAB" to the terminal. Readline converts the input to two escape sequences: "\N{ESC}\x43" == "\N{ESC}C" (Alt + Capital C), which probably runs the “capitalize-word” command, and "\N{ESC}\x2B" == "\N{ESC}+" (Alt + Plus), which presumably generates the bell character. I don’t understand why you say Readline is “correctly” using the C or Posix locale (ASCII), while my understanding is Python on Android always uses UTF-8 as the locale encoding. It seems there is an inconsistency with the locale or encodings being used. Or is this just an obscure case that you choose not to support on Android, and therefore skip the test? -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28997> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28815] test_socket fails if /proc/modules is existent but not readable
Changes by Martin Panter <vadmium...@gmail.com>: -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28815> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29082] In 2.7.13, _ctypes.LoadLibrary no longer accepts Unicode objects
Martin Panter added the comment: Other tests are skipped if libc_name is None, so your assertion is inconsistent. FTR there are reports open about problems with bootstrap files like asdl_c.py, e.g. Issue 28143 proposing to port that file to Python 3, and Issue 23404 about the future of “make touch”. -- stage: needs patch -> patch review ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29082> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21242] Generalize configure check for working Python executable
Martin Panter added the comment: It is still not clear what change you were proposing. Perhaps factor out the common code for ADSLGEN and OPCODEHGEN? If so, that has been done as part of Issue 26662 in 3.5+. -- nosy: +martin.panter superseder: -> configure/Makefile doesn't check if "python" command works, needed to build Objects/typeslots.inc ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21242> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29070] Integration tests for pty.spawn on Linux and all other platforms
Martin Panter added the comment: I would prefer to commit Chris’s fix for BSDs (Issue 26228) with a regression test. I can explain in the commit message who contributed to which part, or do two separate commits if you prefer. But the point is to add the test with the fix. I’m not going to commit the test on its own, because we know it will fail. Even in Lib/test/test_pty.py, it looks like the two patches will collide. I was hoping you could combine the patches, or supply a set of patches that are tested and compatible. I don’t have OS X or BSD so I have to rely on you and the buildbots to confirm that a patch doesn’t break any tests. I haven’t looked too closely regarding the slow tests, but another option is use the “cpu” resource to mark the test as being slow. I realized that PtyWhiteBoxIntegrationTermiosTest is a reasonable test for the termios module, so it is beneficial. Though it may have been simpler to write it using pty.openpty(), avoiding an extra thread that just copies data between other threads. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29070> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29174] 'NoneType' object is not callable in subprocess.py
Martin Panter added the comment: The code in test.py is not realistic. It spawns children only to terminate them straight away, and you could easily reap each child after calling terminate(). You might have more influence with a realistic use case. Victor has committed a fix for the “exception ignored” problem, so assuming it works, in the next release of Python it should be gone. You should still see a ResourceWarning if warnings are enabled, but I don’t think -Wignore would be necessary to suppress them; such warnings are disabled by default. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29174> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27068] Add a detach() method to subprocess.Popen
Martin Panter added the comment: The user can access pipes and close them directly, or keep their own reference. I don’t think detach() should touch pipes, and __exit__() should probably continue to close them. Maybe call the method detach_pid() if that makes it clearer that pipes are unaffected. For the Windows process handle, I suggest detach() should close it. I believe this would make Windows work like Unix when you set SIGCHLD to automatically reap children. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27068> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29174] 'NoneType' object is not callable in subprocess.py
Martin Panter added the comment: The ResourceWarning was added by Issue 26741. I agree that there are legitimate reasons why pre-3.6 code may avoid calling Popen.wait() and equivalent. Victor opened Issue 27068 about adding a Popen.detach() method, which such code could use to opt out of the warning. I don’t think there should be a special exemption for the warning at shutdown time. I think we should either: 1. Accept that you should never destroy a 3.6 Popen object without first “waiting” on its child (or zombie), or: 2. Revert the warning, and in a future release (e.g. 3.7), add it back along with a way to opt out of the warning. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29174> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27632] build on AIX fails when builddir != srcdir, more than bad path to ld_so_aix
Martin Panter added the comment: Regarding reopening Issue 10656, whatever you think is more appropriate. You just have to judge whether it is the same use case, the same code affected, etc. Issue 16189 and Issue 25825 were about updating to match recent changes to directory names, and I thought we decided the changes were not applicable to 2.7. Regarding LDSHARED vs BLDSHARED, isn’t this the same as Issue 28311, which lead to Issue 18235? If you can try the patch I mentioned at <https://bugs.python.org/issue18235#msg277745>, I suspect it may help. Let me know if you need help adapting the patch for 2.7. -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27632> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29172] blake2: Use lowest-common denominator signature of #pragma pack
Martin Panter added the comment: FWIW Issue 28290 was also opened about this pragma directive being not recognized by a compiler called xlC on AIX. -- nosy: +martin.panter ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29172> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29070] Integration tests for pty.spawn on Linux and all other platforms
Martin Panter added the comment: Ignore my comment about contrib agreement, that must have come through recently :) -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29070> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29070] Integration tests for pty.spawn on Linux and all other platforms
Martin Panter added the comment: Hi Cornelius and thanks for the work. Since the patch adds a significant amount of code, I think you might have to sign the contributor agreement: <http://www.python.org/psf/contrib/contrib-form/>. You can do it in a web browser. I would like to review your tests, but because there is a lot of code to understand and I don’t have much time, it might take me a while. If you can find any way to simplify it, that would be great. I have some comments on the code review, and will probably post more as I begin to understand what you are proposing. It looks like you depend on fixing Issue 26228, but the patch there will conflict with your changes. Maybe merge with the other patch, or propose an alternative fix. The documentation currently mentions the code is only tested on Linux, so it would be nice to update that. The patch does introduce behavioural changes, if you consider abuse like monkey-patching os.exec() after importing the pty module. It is best not to make unnecessary changes in a bug fix. Why does the patch slow the tests down so much? Ideally, it is nice to keep the tests as fast as possible. What is the problem with using a genuine exec() call? Why do we need PtyMockingExecTestBase? -- versions: +Python 2.7, Python 3.5 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29070> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26228] pty.spawn hangs on FreeBSD 9.3, 10.x
Martin Panter added the comment: Behaviour change in Free BSD as I understand. Nothing changed in Python, but perhaps older versions of Free BSD behaved like Linux and raised EIO (or another errno; it is not clear). -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26228> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29138] No __hash__() inheritance warning with -Werror
Martin Panter added the comment: Thanks, I will try to look at that some time -- stage: needs patch -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29138> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29138] No __hash__() inheritance warning with -Werror
New submission from Martin Panter: Normally there is a Python 3 compatibility warning emitted when a class is based on object, implements __eq__(), but does not define __hash__(): $ python -3 -c 'class C(object): __eq__ = lambda self, other: True' -c:1: DeprecationWarning: Overriding __eq__ blocks inheritance of __hash__ in 3.x But when warnings are raised as exceptions, this warning seems to be suppressed: $ python -3 -Werror -c 'class C(object): __eq__ = lambda self, other: True' Perhaps there is bad exception handling at the warn() call site. -- messages: 284539 nosy: martin.panter priority: normal severity: normal stage: needs patch status: open title: No __hash__() inheritance warning with -Werror type: behavior versions: Python 2.7 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29138> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29130] Exit code 120 returned from Python unit test testing SystemExit
Martin Panter added the comment: David is right. The 120 code was added in Issue 5319, as a way of indicating a problem in the final stages of the interpreter exiting. The two conditions that trigger this are calling the flush() method on sys.stdout and sys.stderr. If you add a dummy flush() implementation, it no longer exits with 120: >>> subprocess.call((sys.executable, "-c", """ ... class NullWriter: ... def write(self, s): pass ... import sys; sys.stderr = NullWriter()""")) 120 >>> subprocess.call((sys.executable, "-c", """ ... class NullWriter: ... def write(self, s): pass ... def flush(self): pass ... import sys; sys.stderr = NullWriter()""")) 0 It does not seem to be explicitly documented what you can set sys.stderr to, but I always thought it is safest to use an io.TextIOBase implementation. I would suggest to derive your NullWriter class from TextIOBase; that way you get a default flush() implementation for free. Other options are to use StringIO() if you are not expecting too much output, or open(os.devnull, "w"). See also Issue 28864 about adding a predefined class like NullWriter to Python. Having said all that, perhaps it would be reasonable to tolerate a missing flush() method, and not treat this as an error. Stepping back a bit, I also suggest restoring sys.stderr after the test. Otherwise, you risk missing an error message. Try contextlib.redirect_stderr(). -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29130> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28864] Add devnull file-like object
Martin Panter added the comment: Example where an implementation like Serhiy’s was not good enough: <https://bugs.python.org/issue29130#msg284437>. In that case, the lack of flush() method causes a subtle problem. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28864> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com