[issue42937] 192.0.0.8 (IPv4 dummy address) considered globally reachable

2021-05-18 Thread Martijn Pieters
Martijn Pieters added the comment: > Private is a subset of special use. Should a "_special_use" constant be > created. This would include multicast, link_local, private_use, and a few > more. There are already dedicated tests for those other special use networks in i

[issue44167] ipaddress.IPv6Address.is_private makes redundant checks

2021-05-18 Thread Martijn Pieters
Change by Martijn Pieters : -- keywords: +patch pull_requests: +24826 stage: -> patch review pull_request: https://github.com/python/cpython/pull/26209 ___ Python tracker <https://bugs.python.org/issu

[issue42937] 192.0.0.8 (IPv4 dummy address) considered globally reachable

2021-05-18 Thread Martijn Pieters
Martijn Pieters added the comment: Oops, I got my issue numbers mixed up. This is related to #44167, I meant. -- ___ Python tracker <https://bugs.python.org/issue42

[issue42937] 192.0.0.8 (IPv4 dummy address) considered globally reachable

2021-05-18 Thread Martijn Pieters
Martijn Pieters added the comment: This is related to #42937, the IPv4 private network list is not considering the whole of 192.0.0.0/24 to be private. RFC 5736 / 6890 reserved 192.0.0.0/24 for special purposes (private networks) and to date a few subnets of that network have received

[issue44167] ipaddress.IPv6Address.is_private makes redundant checks

2021-05-18 Thread Martijn Pieters
New submission from Martijn Pieters : ipaddress.IPv6Address.is_private uses a hard-coded list of `IPv6Network` objects that cover private networks to test against. This list contains two networks that are subnets of a 3rd network in the list. IP addresses that are not private are tested

[issue30256] Adding a SyncManager Queue proxy to a SyncManager dict or Namespace proxy raises an exception

2020-09-08 Thread Martijn Pieters
Martijn Pieters added the comment: Might it be better to just *drop* the AutoProxy object altogether? All that it adds is a delayed call to MakeProxyType(f"AutoProxy[{typeid}]", exposed) (with exposed defaulting to public_methods(instance)), per instance per process. It could b

[issue40647] Building with a libreadline.so located outside the ld.so.conf search path fails

2020-05-16 Thread Martijn Pieters
Martijn Pieters added the comment: Last but not least, this is essentially a duplicate of https://bugs.python.org/issue4010 -- ___ Python tracker <https://bugs.python.org/issue40

[issue40647] Building with a libreadline.so located outside the ld.so.conf search path fails

2020-05-16 Thread Martijn Pieters
Martijn Pieters added the comment: Actually, this won't do it either, as `self.lib_dirs` already contains the --prefix. Clearly, I just need to add -R=${PREFIX}/lib to CPPFLAGS. -- resolution: -> not a bug ___ Python tracker <

[issue40647] Building with a libreadline.so located outside the ld.so.conf search path fails

2020-05-16 Thread Martijn Pieters
New submission from Martijn Pieters : This issue goes back a long time. The libreadline handling in the modules setup.py doesn't add the location of the readline library to the runtime library paths: self.add(Extension('readline', ['readline.c'], library_dirs

[issue36077] Inheritance dataclasses fields and default init statement

2019-12-05 Thread Martijn Pieters
Martijn Pieters added the comment: I've supported people hitting this issue before (see https://stackoverflow.com/a/53085935/100297, where I used a series of mixin classes to make use of the changing MRO when the mixins share base classes, to enforce a field order from inherited classes

[issue35278] [security] directory traversal in tempfile prefix

2019-11-09 Thread Martijn Pieters
Martijn Pieters added the comment: I found this issue after helping someone solve a Stack Overflow question at https://stackoverflow.com/q/58767241/100297; they eventually figured out that their prefix was a path, not a path element. I'd be all in favour of making tempfile._sanitize_params

[issue38364] inspect.iscoroutinefunction / isgeneratorfunction / isasyncgenfunction can't handle partialmethod objects

2019-10-05 Thread Martijn Pieters
Change by Martijn Pieters : -- keywords: +patch pull_requests: +16188 stage: -> patch review pull_request: https://github.com/python/cpython/pull/16600 ___ Python tracker <https://bugs.python.org/issu

[issue38374] Remove weakref.ReferenceError entry from documentation

2019-10-04 Thread Martijn Pieters
New submission from Martijn Pieters : The weakref documentation still mentions weakref.ReferenceError: https://docs.python.org/3/library/weakref.html#weakref.ReferenceError But this alias for the built-in ReferenceError exception was removed in the 3.0 development cycle (https://github.com

[issue38364] inspect.iscoroutinefunction / isgeneratorfunction / isasyncgenfunction can't handle partialmethod objects

2019-10-03 Thread Martijn Pieters
New submission from Martijn Pieters : This is a follow-up to #33261, which added general support for detecting generator / coroutine / async generator functions wrapped in partials. It appears that partialmethod objects were missed out. While a partialmethod object will produce

[issue37470] Make it explicit what happens when using a bounded queue with QueueHandler

2019-07-01 Thread Martijn Pieters
New submission from Martijn Pieters : The documentation doesn't make it explicit what happens if you use a bounded queue together with logging.handlers.QueueHandler. If the queue is bounded in size and attempts are made to add logrecords faster than a queue listener removes them

[issue37469] Make it explicit that logging QueueHandler / QueueListener accepts a SimpleQueue.

2019-07-01 Thread Martijn Pieters
New submission from Martijn Pieters : The implementation of the logging.handler.QueueHandler and logging.handler.QueueListener does not make use of the task tracking API of queues (queue.task_done(), queue.join()) nor does it care if the queue is unbounded (queue.full(), catching the Full

[issue12169] Factor out common code for d2 commands register, upload and upload_docs

2019-03-04 Thread Martijn Pieters
Change by Martijn Pieters : -- pull_requests: +12168 ___ Python tracker <https://bugs.python.org/issue12169> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue12169] Factor out common code for d2 commands register, upload and upload_docs

2019-03-04 Thread Martijn Pieters
Change by Martijn Pieters : -- pull_requests: -12166 ___ Python tracker <https://bugs.python.org/issue12169> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue36188] Remove vestiges of Python 2 unbound methods from Python 3

2019-03-04 Thread Martijn Pieters
Change by Martijn Pieters : -- keywords: +patch pull_requests: +12167 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue36188> ___ _

[issue36188] Remove vestiges of Python 2 unbound methods from Python 3

2019-03-04 Thread Martijn Pieters
New submission from Martijn Pieters : The implementation of method_hash, method_call and method_descr_get all still contain assumptions that __self__ can be set to None, a holdover from Python 2 where methods could be *unbound*. These vestiges can safely be removed, because method_new

[issue12169] Factor out common code for d2 commands register, upload and upload_docs

2019-03-04 Thread Martijn Pieters
Change by Martijn Pieters : -- pull_requests: +12166 ___ Python tracker <https://bugs.python.org/issue12169> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue36002] configure --enable-optimizations with clang fails to detect llvm-profdata

2019-02-15 Thread Martijn Pieters
New submission from Martijn Pieters : This is probably a automake bug. When running CC=clang CXX=clang++ ./configure --enable-optimizations, configure tests for a non-existing -llvm-profdata binary: checking for --enable-optimizations... yes checking for --with-lto... no checking for -llvm

[issue35805] email package folds msg-id identifiers using RFC2047 encoded words where it must not

2019-01-22 Thread Martijn Pieters
New submission from Martijn Pieters : When encountering identifier headers such as Message-ID containing a msg-id token longer than 77 characters (including the <...> angle brackets), the email package folds that header using RFC 2047 encoded words, e.g. Mess

[issue35654] Remove 'guarantee' that sorting only relies on __lt__ from sorting howto

2019-01-04 Thread Martijn Pieters
Martijn Pieters added the comment: (I have no opinion on this having to be a language feature however) -- ___ Python tracker <https://bugs.python.org/issue35

[issue35654] Remove 'guarantee' that sorting only relies on __lt__ from sorting howto

2019-01-04 Thread Martijn Pieters
Martijn Pieters added the comment: Well, if this is indeed by design (and I missed the list.sort() reference) then I agree the HOWTO should not be changed! I'd be happy to change this to asking for more explicit mentions in the docs for sorted, heapq and bisect that using only < (__l

[issue35654] Remove 'guarantee' that sorting only relies on __lt__ from sorting howto

2019-01-03 Thread Martijn Pieters
New submission from Martijn Pieters : Currently, the sorting HOWTO at https://docs.python.org/3/howto/sorting.html#odd-and-ends contains the text: > The sort routines are guaranteed to use __lt__() when making comparisons > between two objects. So, it is easy to add a standard sort

[issue35547] email.parser / email.policy does not correctly handle multiple RFC2047 encoded-word tokens across RFC5322 folded headers

2018-12-21 Thread Martijn Pieters
Martijn Pieters added the comment: While RFC2047 clearly states that an encoder MUST not split multi-byte encodings in the middle of a character (section 5, "Each 'encoded-word' MUST represent an integral number of characters. A multi-octet character may not be split across adj

[issue35547] email.parser / email.policy does correctly handle multiple RFC2047 encoded-word tokens across RFC5322 folded headers

2018-12-20 Thread Martijn Pieters
Martijn Pieters added the comment: That regex is incorrect, I should not post untested code from a mobile phone. Corrected workaround with more context: import re from email.policy import EmailPolicy class UnfoldingEncodedStringHeaderPolicy(EmailPolicy): def header_fetch_parse(self

[issue35547] email.parser / email.policy does correctly handle multiple RFC2047 encoded-word tokens across RFC5322 folded headers

2018-12-20 Thread Martijn Pieters
Martijn Pieters added the comment: Right, re-educating myself on the MIME RFCs, and found https://bugs.python.org/issue1372770 where the same issue is being discussed for previous incarnations of the email library. Removing the FWS after CRLF is the wrong thing to do, **unless** RFC2047

[issue35547] email.parser / email.policy does correctly handle multiple RFC2047 encoded-word tokens across RFC5322 folded headers

2018-12-20 Thread Martijn Pieters
Change by Martijn Pieters : -- components: +email nosy: +barry, r.david.murray type: -> behavior versions: +Python 3.7 ___ Python tracker <https://bugs.python.org/issu

[issue35547] email.parser / email.policy does correctly handle multiple RFC2047 encoded-word tokens across RFC5322 folded headers

2018-12-20 Thread Martijn Pieters
New submission from Martijn Pieters : The From header in the following email headers is not correctly decoded; both the subject and from headers contain UTF-8 encoded data encoded with RFC2047 encoded-words, in both cases a multi-byte UTF-8 codepoint has been split between the two encoded

[issue35366] Monkey Patching class derived from ctypes.Union doesn't work

2018-11-30 Thread Martijn Pieters
Martijn Pieters added the comment: This is a repeat of old-tracker issue 1700288, see https://github.com/python/cpython/commit/08ccf202e606a08f4ef85df9a9c0d07e1ba1#diff-998bfefaefe2ab83d5f523e18f158fa4, which fixed this for StructType_setattro but failed to do the same

[issue26832] ProactorEventLoop doesn't support stdin/stdout nor files with connect_read_pipe/connect_write_pipe

2018-09-11 Thread Martijn Pieters
Martijn Pieters added the comment: I'm trying to figure out why Windows won't let us do this. I think the reason is that sys.std(in|out) filehandles are not opened as pipes, and do not have the required OVERLAPPED flag set (see the CreateIoCompletionPort documentation at https

[issue33567] Explicitly mention bytes and other buffers in the documentation for float()

2018-05-18 Thread Martijn Pieters
New submission from Martijn Pieters <m...@python.org>: float(bytesobject) treats the contents of the bytesobject as a sequence of ASCII characters, and converts those to a float value as if you used float(bytesobject.decode('ASCII')). The same support is extended to other objects implem

[issue33516] unittest.mock: Add __round__ to supported magicmock methods

2018-05-15 Thread Martijn Pieters
New submission from Martijn Pieters <m...@python.org>: I notice that __trunc__, __floor__ and __ceil__ are supported methods for MagicMock, but __round__ (in the same grouping of numeric types emulation methods, see https://docs.python.org/3/reference/datamodel.html#object.__r

[issue33492] Updating the Evaluation order section to cover *expression in calls

2018-05-14 Thread Martijn Pieters
New submission from Martijn Pieters <m...@python.org>: Can the *Evaluation order* (_evalorder) section in reference/expressions.rst please be updated to cover this exception in a *call* primary (quoting from the _calls section): A consequence of this is that although the ``*expr

[issue32963] Python 2.7 tutorial claims source code is UTF-8 encoded

2018-03-03 Thread Martijn Pieters
Martijn Pieters <m...@python.org> added the comment: Thanks for the quick fix, sorry I didn't have a PR for this one! -- ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

[issue32963] Python 2.7 tutorial claims source code is UTF-8 encoded

2018-02-27 Thread Martijn Pieters
Change by Martijn Pieters <m...@python.org>: -- nosy: +Mariatta, rhettinger ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

[issue32963] Python 2.7 tutorial claims source code is UTF-8 encoded

2018-02-27 Thread Martijn Pieters
New submission from Martijn Pieters <m...@python.org>: Issue #29381 updated the tutorial to clarify #! use, but the 2.7 patch re-used Python 3 material that doesn't apply. See r40ba60f6 at https://github.com/python/cpython/commit/40ba60f6bf2f7192f86da395c71348d0fa24da09 It now

[issue32836] Symbol table for comprehensions (list, dict, set) still includes temporary _[1] variable

2018-02-12 Thread Martijn Pieters
New submission from Martijn Pieters <m...@python.org>: In Python 2.6, a list comprehension was implemented in the current scope using a temporary _[1] variable to hold the list object: >>> import dis >>> dis.dis(compile('[x for x in y]', '?', 'exec')) 1 0 BU

[issue32112] Should uuid.UUID() accept another UUID() instance?

2017-11-22 Thread Martijn Pieters
New submission from Martijn Pieters <m...@python.org>: When someone accidentally passes in an existing uuid.UUID() instance into uuid.UUID(), an attribute error is thrown because it is not a hex string: >>> import uuid >>> value = uuid.uuid4() >>> uuid.UUID(v

[issue31161] Only check for print and exec parentheses cases for SyntaxError, not subclasses

2017-08-13 Thread Martijn Pieters
Changes by Martijn Pieters <m...@python.org>: -- pull_requests: +3125 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue31161> ___ _

[issue31161] Only check for print and exec parentheses cases for SyntaxError, not subclasses

2017-08-13 Thread Martijn Pieters
Changes by Martijn Pieters <m...@python.org>: -- pull_requests: +3124 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue31161> ___ _

[issue31161] Only check for print and exec parentheses cases for SyntaxError, not subclasses

2017-08-13 Thread Martijn Pieters
Martijn Pieters added the comment: Disregard my last message, I misread Serhiy's sentence (read 'correct' for 'incorrect'). -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue31161] Only check for print and exec parentheses cases for SyntaxError, not subclasses

2017-08-13 Thread Martijn Pieters
Martijn Pieters added the comment: This does not increase clarity. It creates confusion. There are two distinct syntax errors, and they should be reported separately, just like `print "abc" 42` is two syntax errors; you'll hear about the second one once the first on

[issue31161] Only check for print and exec parentheses cases for SyntaxError, not subclasses

2017-08-10 Thread Martijn Pieters
Martijn Pieters added the comment: It's confusing; a syntax error reports on the first error found, not two errors at once. The TabError or IndentationError exception detail message itself is lost (it should be "IndentationError: Improper mixture of spaces and tabs." or "Tab

[issue31161] Only check for print and exec parentheses cases for SyntaxError, not subclasses

2017-08-09 Thread Martijn Pieters
Martijn Pieters added the comment: Credit for uncovering this gem: https://stackoverflow.com/questions/45591883/why-is-an-indentionerror-being-raised-here-rather-than-a-syntaxerror -- ___ Python tracker <rep...@bugs.python.org>

[issue31161] Only check for print and exec parentheses cases for SyntaxError, not subclasses

2017-08-09 Thread Martijn Pieters
New submission from Martijn Pieters: SyntaxError.__init__() checks for the `print` and `exec` error cases where the user forgot to use parentheses: >>> exec 1 File "", line 1 exec 1 ^ SyntaxError: Missing parentheses in call to 'exec' >>> print 1

[issue30524] iter(classmethod, sentinel) broken for Argument Clinic class methods?

2017-05-31 Thread Martijn Pieters
Martijn Pieters added the comment: Forgot to addthis: this bug was found via https://stackoverflow.com/questions/44283540/iter-not-working-with-datetime-now -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue30524] iter(classmethod, sentinel) broken for Argument Clinic class methods?

2017-05-31 Thread Martijn Pieters
New submission from Martijn Pieters: I'm not sure where exactly the error lies, but issue 27128 broke iter() for Argument Clinic class methods. The following works in Python 3.5, but not in Python 3.6: from datetime import datetime from asyncio import Task next(iter(datetime.now, None)) next

[issue30293] Peephole binops folding can lead to memory and bytecache ballooning

2017-05-09 Thread Martijn Pieters
Martijn Pieters added the comment: Thanks Raymond, for the response. I agree, we can't prevent all possible misuse, and avoiding the memory issue would require overly costly checks as to what is being multiplied or added. -- ___ Python tracker <

[issue30293] Peephole binops folding can lead to memory and bytecache ballooning

2017-05-06 Thread Martijn Pieters
New submission from Martijn Pieters: The following expression produces 127MB in constants in `co_consts` due to two 63.5MB integer objects produced when folding: ((200*200 - 2) & ((1 << 5) - 1)) + ((200*200 - 2) >> 5) The optimizer already does not

[issue30154] subprocess.run with stderr connected to a pipe won't timeout when killing a never-ending shell commanad

2017-04-24 Thread Martijn Pieters
Martijn Pieters added the comment: Apologies, I copied the wrong sleep 10 demo. The correct demo is: cat >test.sh< #!/bin/sh > sleep 10 > EOF time bin/python -c "import subprocess; subprocess.run(['./test.sh'], stderr=subprocess.PIPE, timeout=3)" Traceback (most rec

[issue30154] subprocess.run with stderr connected to a pipe won't timeout when killing a never-ending shell commanad

2017-04-24 Thread Martijn Pieters
New submission from Martijn Pieters: You can't time out a process tree that includes a never-ending process, *and* which redirects stderr: cat >test.sh< /dev/null # never-ending EOF chmod +x test.sh python -c "import subprocess; subprocess.run(['./test.sh'], stderr=subprocess.PIPE

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

2017-03-01 Thread Martijn Pieters
Changes by Martijn Pieters <m...@python.org>: -- pull_requests: +318 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28598> ___ _

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

2017-02-28 Thread Martijn Pieters
Martijn Pieters added the comment: > Is 2.7 free from this bug? No, 2.7 is affected too: >>> class SubclassedStr(str): ... def __rmod__(self, other): ... return 'Success, self.__rmod__({!r}) was called'.format(other) ... >>> 'lhs %% %r' % SubclassedS

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

2017-02-27 Thread Martijn Pieters
Changes by Martijn Pieters <m...@python.org>: -- pull_requests: +299 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28598> ___ _

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

2017-02-27 Thread Martijn Pieters
Changes by Martijn Pieters <m...@python.org>: -- pull_requests: +294 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28598> ___ _

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

2017-02-14 Thread Martijn Pieters
Changes by Martijn Pieters <m...@python.org>: -- pull_requests: +57 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28598> ___ _

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

2017-02-12 Thread Martijn Pieters
Martijn Pieters added the comment: I'm not sure if issues are linked automatically yet. I put the patch up as a pull request on GitHub: https://github.com/python/cpython/pull/51 -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.p

[issue12268] file readline, readlines & readall methods can lose data on EINTR

2016-11-15 Thread Martijn Pieters
Martijn Pieters added the comment: Follow-up bug, readahead was missed: http://bugs.python.org/issue1633941 -- nosy: +mjpieters ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue1633941] for line in sys.stdin: doesn't notice EOF the first time

2016-11-15 Thread Martijn Pieters
Martijn Pieters added the comment: It looks like readahead was missed when http://bugs.python.org/issue12268 was fixed. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/iss

[issue21090] File read silently stops after EIO I/O error

2016-11-15 Thread Martijn Pieters
Martijn Pieters added the comment: The Python 2.7 issue (using fread without checking for interrupts) looks like a duplicate of http://bugs.python.org/issue1633941 -- nosy: +mjpieters ___ Python tracker <rep...@bugs.python.org>

[issue1633941] for line in sys.stdin: doesn't notice EOF the first time

2016-11-15 Thread Martijn Pieters
Martijn Pieters added the comment: This bug affects all use of `file.__iter__` and interrupts (EINTR), not just sys.stdin. You can reproduce the issue by reading from a (slow) pipe in a terminal window and resizing that window, for example; the interrupt is not handled and a future call ends

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

2016-11-03 Thread Martijn Pieters
Martijn Pieters added the comment: Here's a proposed patch for tip; what versions would it be worth backporting this to? (Note, there's no NEWS update in this patch). -- keywords: +patch Added file: http://bugs.python.org/file45338/issue28598.patch

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

2016-11-03 Thread Martijn Pieters
New submission from Martijn Pieters: The `BINARY_MODULO` operator hardcodes a test for `PyUnicode`: TARGET(BINARY_MODULO) { PyObject *divisor = POP(); PyObject *dividend = TOP(); PyObject *res = PyUnicode_CheckExact(dividend

[issue27797] ASCII file with UNIX line conventions and enough lines throws SyntaxError when ASCII-compatible codec is declared

2016-08-19 Thread Martijn Pieters
New submission from Martijn Pieters: To reproduce, create an ASCII file with > io.DEFAULT_BUFFER_SIZE bytes (can be blank lines) and *UNIX line endings*, with the first two lines reading: #!/usr/bin/env python # -*- coding: cp1252 -*- Try to run this as a script on Windows:

[issue27078] Make f'' strings faster than .format: BUILD_STRING opcode?

2016-05-21 Thread Martijn Pieters
Martijn Pieters added the comment: The catalyst for this question was a Stack Overflow question I answered: https://stackoverflow.com/questions/37365311/why-are-python-3-6-literal-formatted-strings-so-slow Compared the `str.format()` the BUILD_LIST is the bottleneck here; dropping

[issue27078] Make f'' strings faster than .format: BUILD_STRING opcode?

2016-05-21 Thread Martijn Pieters
Changes by Martijn Pieters <m...@python.org>: -- nosy: +mjpieters ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27078> ___ __

[issue26650] calendar: OverflowErrors for year == 1 and firstweekday > 0

2016-03-27 Thread Martijn Pieters
New submission from Martijn Pieters: For anything other than calendar.Calendar(0), many methods lead to OverflowError exceptions: >>> import calendar >>> c = calendar.Calendar(0) >>> list(c.itermonthdays(1, 1)) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,

[issue26477] typing forward references and module attributes

2016-03-03 Thread Martijn Pieters
Martijn Pieters added the comment: > I wonder why they forward references are evaluated *at all* at this point. The Union type tries to reduce the set of allowed types by removing any subclasses (so Union[int, bool] becomes Union[int] only). That's all fine, but it should not at that po

[issue26477] typing forward references and module attributes

2016-03-03 Thread Martijn Pieters
Martijn Pieters added the comment: A temporary work-around is to use a function to raise a NameError exception when the module attribute doesn't exist yet: def _forward_A_reference(): try: return a.A except AttributeError: # not yet.. raise NameError('A') class

[issue26477] typing forward references and module attributes

2016-03-03 Thread Martijn Pieters
Martijn Pieters added the comment: Sorry, that should have read "the forward references section of PEP 484". The section uses this example: # File models/a.py from models import b class A(Model): def foo(self, b: 'b.B'): ... # File models/b.py from models import a class B(Model

[issue26477] typing forward references and module attributes

2016-03-03 Thread Martijn Pieters
New submission from Martijn Pieters: Forward references to a module can fail, if the module doesn't yet have the required object. The "forward references" section names circular dependencies as one use for forward references, but the following example fails: $ cat test/__init

[issue26449] Tutorial on Python Scopes and Namespaces uses confusing 'read-only' terminology

2016-02-29 Thread Martijn Pieters
Martijn Pieters added the comment: +1 for "... can only be read". read-only can too easily be construed to mean that the variable cannot be set from *anywhere*, even the original scope. Another alternative would be "... is effectively read-only", but "... can

[issue26449] Tutorial on Python Scopes and Namespaces uses confusing 'read-only' terminology

2016-02-27 Thread Martijn Pieters
Changes by Martijn Pieters <m...@python.org>: -- assignee: -> docs@python components: +Documentation nosy: +docs@python ___ Python tracker <rep...@bugs.python.org> <http://bugs.pyt

[issue26449] Tutorial on Python Scopes and Namespaces uses confusing 'read-only' terminology

2016-02-27 Thread Martijn Pieters
New submission from Martijn Pieters: >From the 9.2. Python Scopes and Namespace section: > If a name is declared global, then all references and assignments go directly > to the middle scope containing the module’s global names. To rebind variables > found outside of the inn

[issue24856] Mock.side_effect as iterable or iterator

2015-08-13 Thread Martijn Pieters
New submission from Martijn Pieters: The documentation states that `side_effect` can be set to an [iterable](https://docs.python.org/3/glossary.html#term-iterable): If you pass in an iterable, it is used to retrieve an iterator which must yield a value on every call. This value can either

[issue24856] Mock.side_effect as iterable or iterator

2015-08-13 Thread Martijn Pieters
Martijn Pieters added the comment: Bugger, that's the last time I take someone's word for it and not test properly. Indeed, I missed the inheritance of NonCallableMock, so the property is inherited from there. Mea Culpa! -- ___ Python tracker rep

[issue12892] UTF-16 and UTF-32 codecs should reject (lone) surrogates

2015-08-10 Thread Martijn Pieters
Martijn Pieters added the comment: I don't understand why encoding with `surrogateescape` isn't supported still; is it the fact that a surrogate would have to produce *single bytes* rather than double? E.g. b'\x80' - '\udc80' - b'\x80' doesn't work because that would mean the UTF-16 and UTF

[issue23495] The writer.writerows method should be documented as accepting any iterable (not only a list)

2015-04-30 Thread Martijn Pieters
Martijn Pieters added the comment: I'd be happy to provide a patch for the DictWriter.writerows code; I was naively counting on it accepting an iterable and that it would not pull the whole sequence into memory (while feeding it gigabytes of CSV data). -- nosy: +mjpieters

[issue23864] issubclass without registration only works for one-trick pony collections ABCs.

2015-04-04 Thread Martijn Pieters
New submission from Martijn Pieters: The collections.abc documentation implies that *any* of the container ABCs can be used in an issubclass test against a class that implements all abstract methods: These ABCs allow us to ask classes or instances if they provide particular functionality

[issue23864] issubclass without registration only works for one-trick pony collections ABCs.

2015-04-04 Thread Martijn Pieters
Martijn Pieters added the comment: I should have added the mixin methods for the Sequence implementation; the more complete demonstration is: from collections.abc import Sequence, Container, Sized class MySequence(object): ... def __contains__(self, item): pass ... def __len__(self

[issue23730] Document return value for ZipFile.extract()

2015-03-21 Thread Martijn Pieters
New submission from Martijn Pieters: The documentation for zipfile.ZipFile.extract() doesn't mention at all that it returns the local path created, either for the directory that the member represents, or the new file created from the zipped data. *Returns the full local path created

[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-04 Thread Martijn Pieters
Martijn Pieters added the comment: I like the unicode.__getitem__(s, slice(None)) approach, it has the advantage of not having to rely on len(s). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23583

[issue19481] IDLE hangs while printing instance of Unicode subclass

2015-03-04 Thread Martijn Pieters
Martijn Pieters added the comment: This changes causes printing BeautifulSoup NavigableString objects to fail; the code actually could never work as `unicode.__getslice__` insists on getting passed in integers, not None. To reproduce, create a new file in IDLE and paste in: from bs4 import

[issue19481] IDLE hangs while printing instance of Unicode subclass

2015-03-04 Thread Martijn Pieters
Martijn Pieters added the comment: Created a new issue: http://bugs.python.org/issue23583 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19481

[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-04 Thread Martijn Pieters
New submission from Martijn Pieters: This is a regression or recurrence of issue #19481. To reproduce, create a subclass of unicode and try and print an instance of that class: class Foo(unicode): pass print Foo() results in a traceback: Traceback (most recent call last): File pyshell#4

[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-04 Thread Martijn Pieters
Changes by Martijn Pieters m...@python.org: -- components: +IDLE ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23583 ___ ___ Python-bugs-list

[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-04 Thread Martijn Pieters
Martijn Pieters added the comment: Proposed fix, replace line 1352-1353 in PseudoOutputFile.write(): if isinstance(s, unicode): s = unicode.__getslice__(s, None, None) with if isinstance(s, unicode): s = unicode.__getslice__(s, 0, len(s

[issue7334] ElementTree: file locking in Jython 2.5 (OSError on Windows)

2015-01-22 Thread Martijn Pieters
Martijn Pieters added the comment: Indeed, the 2.7 backport was not correctly applied for _elementtree.c, leaving files open because the close_source flag is set to False *again* when opening a filename. Should a new issue be opened or should this ticket be re-opened? -- nosy

[issue17876] Doc issue with threading.Event

2014-12-16 Thread Martijn Pieters
Martijn Pieters added the comment: I notice that the same issue still exists in the 3.5 documentation. Surely this can at least be fixed in the development copy? -- nosy: +mjpieters ___ Python tracker rep...@bugs.python.org http://bugs.python.org

[issue17876] Doc issue with threading.Event

2014-12-16 Thread Martijn Pieters
Martijn Pieters added the comment: Ah! Mea Culpa, you are correct. The issue is then with Python 2.7 only for which no doubt exists a separate ticket. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17876

[issue22755] contextlib.closing documentation should use a new example

2014-10-28 Thread Martijn Pieters
New submission from Martijn Pieters: urllib.request.urlopen() now always produces a context manager (either a HTTPResponse or addinfourl object). The example for contextlib.closing still uses urllib.request.urlopen as an example for the context manager wrapper, see https://docs.python.org

[issue13769] json.dump(ensure_ascii=False) return str instead of unicode

2014-10-23 Thread Martijn Pieters
Martijn Pieters added the comment: I'd say this is a bug in the library, not the documentation. The library varies the output type, making it impossible to use `json.dump()` with a `io.open()` object as the library will *mix data type* when writing. That is *terrible* behaviour

[issue22575] bytearray documentation confuses string for unicode objects

2014-10-07 Thread Martijn Pieters
New submission from Martijn Pieters: The Python 2 version of the bytearray() documentation appears to be copied directly from its Python 3 counterpart and states that when passing in a string an encoding is required: * If it is a string, you must also give the encoding (and optionally, errors

[issue22288] Incorrect Call grammar in documentation

2014-08-28 Thread Martijn Pieters
Martijn Pieters added the comment: Fixed by revision 3ae399c6ecf6 -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22288

[issue3473] In function call, keyword arguments could follow *args

2014-08-27 Thread Martijn Pieters
Martijn Pieters added the comment: The documentation change in this patch introduced a bug in the Call grammar: | * `expression` [, * `expression`] [, ** `expression`] instead of | * `expression` [, `keyword_arguments`] [, ** `expression`] giving the impression that `*expression` is allowed

[issue22288] Incorrect Call grammar in documentation

2014-08-27 Thread Martijn Pieters
New submission from Martijn Pieters: The changes for issue #3473 introduced a documentation bug. The Call expression grammar implies that f(*[1, 2], *[3, 4]) is allowed: | * `expression` [, * `expression`] [, ** `expression`] I think Benjamin meant to use: | * `expression

[issue22288] Incorrect Call grammar in documentation

2014-08-27 Thread Martijn Pieters
Martijn Pieters added the comment: Proposed fix added in my fork. -- hgrepos: +270 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22288

  1   2   >