[issue46065] re.findall takes forever and never ends

2021-12-19 Thread Gareth Rees
Gareth Rees added the comment: This kind of question is frequently asked (#3128, #29977, #28690, #30973, #1737127, etc.), and so maybe it deserves an answer somewhere in the Python documentation. -- resolution: -> wont fix stage: -> resolved status: open -&g

[issue46065] re.findall takes forever and never ends

2021-12-19 Thread Gareth Rees
Gareth Rees added the comment: The way to avoid this behaviour is to disallow the attempts at matching that you know are going to fail. As Serhiy described above, if the search fails starting at the first character of the string, it will move forward and try again starting at the second

[issue15443] datetime module has no support for nanoseconds

2021-12-18 Thread Gareth Rees
Gareth Rees added the comment: I also have a use case that would benefit from nanosecond resolution in Python's datetime objects, that is, representing and querying the results of clock_gettime() in a program trace. On modern Linuxes with a vDSO, clock_gettime() does not require a system

[issue45643] SIGSTKFLT is missing from the signals module on Linux

2021-11-17 Thread Gareth Rees
Gareth Rees added the comment: Tagging vstinner as you have touched Modules/signalmodule.c a few times in the last year. What do you think? -- nosy: +vstinner ___ Python tracker <https://bugs.python.org/issue45

[issue45643] SIGSTKFLT is missing from the signals module on Linux

2021-10-28 Thread Gareth Rees
Change by Gareth Rees : -- keywords: +patch pull_requests: +27529 stage: -> patch review pull_request: https://github.com/python/cpython/pull/29266 ___ Python tracker <https://bugs.python.org/issu

[issue45643] SIGSTKFLT is missing from the signals module on Linux

2021-10-28 Thread Gareth Rees
New submission from Gareth Rees : BACKGROUND On Linux, "man 7 signal" includes SIGSTKFLT in its table of "various other signals": Signal Value Action Comment ─── SIGSTKFLT -,16,-

[issue45476] [C API] Convert "AS" functions, like PyFloat_AS_DOUBLE(), to static inline functions

2021-10-15 Thread Gareth Rees
Gareth Rees added the comment: If the problem is accidental use of the result of PyFloat_AS_DOUBLE() as an lvalue, why not use the comma operator to ensure that the result is an rvalue? The C99 standard says "A comma operator does not yield an lvalue" in §6.5.17; I imagine there

[issue41092] Report actual size from 'os.path.getsize'

2020-06-26 Thread Gareth Rees
Gareth Rees added the comment: The proposed change adds a Boolean flag to os.path.getsize() so that it returns: os.stat(filename).st_blocks * 512 (where the 512 is the file system block size on Linux; some work is needed to make this portable to other operating systems). The Boolean

[issue40707] Popen.communicate documentation does not say how to get the return code

2020-06-23 Thread Gareth Rees
Gareth Rees added the comment: Is there anything I can do to move this forward? -- ___ Python tracker <https://bugs.python.org/issue40707> ___ ___ Python-bug

[issue40707] Popen.communicate documentation does not say how to get the return code

2020-05-23 Thread Gareth Rees
Gareth Rees added the comment: The following test cases in test_subprocess.py call the communicate() method and then immediately assert that returncode attribute has the expected value: * test_stdout_none * test_stderr_redirect_with_no_stdout_redirect * test_stdout_filedes_of_stdout

[issue40707] Popen.communicate documentation does not say how to get the return code

2020-05-21 Thread Gareth Rees
Change by Gareth Rees : -- keywords: +patch pull_requests: +19559 stage: -> patch review pull_request: https://github.com/python/cpython/pull/20283 ___ Python tracker <https://bugs.python.org/issu

[issue40707] Popen.communicate documentation does not say how to get the return code

2020-05-21 Thread Gareth Rees
New submission from Gareth Rees : When using subprocess.Popen.communicate(), it is natural to wonder how to get the exit code of the subprocess. However, the documentation [1] says: Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file

[issue17005] Add a topological sort algorithm

2020-01-09 Thread Gareth Rees
Gareth Rees added the comment: I'd like to push back on the idea that graphs with isolated vertices are "unusual cases" as suggested by Raymond. A very common use case (possibly the most common) for topological sorting is job scheduling. In this use case you have a collection of

[issue17005] Add a topological sort algorithm

2019-01-18 Thread Gareth Rees
Gareth Rees added the comment: Just to elaborate on what I mean by "bug magnet". (I'm sure Pablo understands this, but there may be other readers who would like to see it spelled out.) Suppose that you have a directed graph represented as a mapping from a vertex to an iterable

[issue17005] Add a topological sort algorithm

2019-01-18 Thread Gareth Rees
Gareth Rees added the comment: I approve in general with the principle of including a topological sort algorithm in the standard library. However, I have three problems with the approach in PR 11583: 1. The name "topsort" is most naturally parsed as "top sort" which coul

[issue32194] When creating list of dictionaries and updating datetime objects one by one, all values are set to last one of the list.

2017-12-01 Thread Gareth Rees
Gareth Rees <g...@garethrees.org> added the comment: The behaviour of the * operator (and the associated gotcha) is documented under "Common sequence operations" [1]: Note that items in the sequence s are not copied; they are referenced multiple times. This often h

[issue31895] Native hijri calendar support

2017-10-30 Thread Gareth Rees
Gareth Rees <g...@garethrees.org> added the comment: convertdate does not document which version of the Islamic calendar it uses, but looking at the source code, it seems that it uses a rule-based calendar which has a 30-year cycle with 11 leap years. This won't help Haneef, who wants t

[issue31895] Native hijri calendar support

2017-10-30 Thread Gareth Rees
Gareth Rees <g...@garethrees.org> added the comment: It is a substantial undertaking, requiring a great deal of expertise, to implement the Islamic calendar. The difficulty is that there are multiple versions of the calendar. In some places the calendar is based on human obser

[issue28647] python --help: -u is misdocumented as binary mode

2017-10-11 Thread Gareth Rees
Gareth Rees <g...@garethrees.org> added the comment: You're welcome. -- ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue28647> ___

[issue24869] shlex lineno inaccurate with certain inputs

2017-07-21 Thread Gareth Rees
Gareth Rees added the comment: I've made a pull request. (Not because I expect it to be merged as-is, but to provide a starting point for discussion.) -- nosy: +petri.lehtinen, vinay.sajip ___ Python tracker <rep...@bugs.python.org>

[issue24869] shlex lineno inaccurate with certain inputs

2017-07-21 Thread Gareth Rees
Changes by Gareth Rees <g...@garethrees.org>: -- pull_requests: +2849 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24869> ___ _

[issue30976] multiprocessing.Process.is_alive can show True for dead processes

2017-07-20 Thread Gareth Rees
Gareth Rees added the comment: This is a race condition — when os.kill returns, that means that the signal has been delivered, but it does not mean that the subprocess has exited yet. You can see this by inserting a sleep after the kill and before the liveness check: print(proc.is_alive

[issue30973] Regular expression "hangs" interpreter

2017-07-20 Thread Gareth Rees
Gareth Rees added the comment: This is the usual exponential backtracking behaviour of Python's regex engine. The problem is that the regex (?:[^*]+|\*[^/])* can match against a string in exponentially many ways, and Python's regex engine tries all of them before giving up

[issue19896] Exposing "q" and "Q" to multiprocessing.sharedctypes

2017-07-17 Thread Gareth Rees
Changes by Gareth Rees <g...@garethrees.org>: -- pull_requests: +2801 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19896> ___ _

[issue19896] Exposing "q" and "Q" to multiprocessing.sharedctypes

2017-07-17 Thread Gareth Rees
Gareth Rees added the comment: (If he hasn't, I don't think I can make a PR because I read his patch and so any implementation I make now is based on his patch and so potentially infringes his copyright.) -- ___ Python tracker <

[issue19896] Exposing "q" and "Q" to multiprocessing.sharedctypes

2017-07-17 Thread Gareth Rees
Gareth Rees added the comment: Has Antony Lee has made a copyright assignment? -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue19896] Exposing "q" and "Q" to multiprocessing.sharedctypes

2017-07-17 Thread Gareth Rees
Changes by Gareth Rees <g...@garethrees.org>: -- nosy: +benjamin.peterson ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19896> ___

[issue30943] printf-style Bytes Formatting sometimes do not worked.

2017-07-17 Thread Gareth Rees
Gareth Rees added the comment: This was already noted in issue29714 and fixed by Xiang Zhang in commit b76ad5121e2. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue30943] printf-style Bytes Formatting sometimes do not worked.

2017-07-17 Thread Gareth Rees
Gareth Rees added the comment: Test case minimization: Python 3.6.1 (default, Apr 24 2017, 06:18:27) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin Type "help", "copyright", "credits" or "license" for more informa

[issue19896] Exposing "q" and "Q" to multiprocessing.sharedctypes

2017-07-14 Thread Gareth Rees
Gareth Rees added the comment: Patch looks good to me. The test cases are not very systematic (why only int, double, and long long?), but that's not the fault of the patch and shouldn't prevent its being applied. -- nosy: +g...@garethrees.org

[issue30919] Shared Array Memory Allocation Regression

2017-07-14 Thread Gareth Rees
Gareth Rees added the comment: I propose: 1. Ask Richard Oudkerk why in changeset 3b82e0d83bf9 the temporary file is zero-filled and not truncated. Perhaps there's some file system where this is necessary? (I tested HFS+ which doesn't support sparse files, and zero-filling seems

[issue30919] Shared Array Memory Allocation Regression

2017-07-14 Thread Gareth Rees
Gareth Rees added the comment: I see now that the default start method is 'fork' (except on Windows), so calling set_start_method is unnecessary. Note that you don't have to edit multiprocessing/heap.py, you can "monkey-patch" it in the program that needs the anonymous mapping:

[issue30919] Shared Array Memory Allocation Regression

2017-07-14 Thread Gareth Rees
Gareth Rees added the comment: Nonetheless this is bound to be a nasty performance for many people doing big data processing with NumPy/SciPy/Pandas and multiprocessing and moving from 2 to 3, so even if it can't be fixed, the documentation ought to warn about the problem and explain how

[issue30919] Shared Array Memory Allocation Regression

2017-07-14 Thread Gareth Rees
Gareth Rees added the comment: If you need the 2.7 behaviour (anonymous mappings) in 3.5 then you can still do it, with some effort. I think the approach that requires the smallest amount of work would be to ensure that subprocesses are started using fork(), by calling

[issue30919] Shared Array Memory Allocation Regression

2017-07-13 Thread Gareth Rees
Gareth Rees added the comment: Note that some filesystems (e.g. HFS+) don't support sparse files, so creating a large Arena will still be slow on these filesystems even if the file is created using ftruncate(). (This could be fixed, for the "fork" start method only, by using anon

[issue30919] Shared Array Memory Allocation Regression

2017-07-13 Thread Gareth Rees
Gareth Rees added the comment: In Python 2.7, multiprocessing.heap.Arena uses an anonymous memory mapping on Unix. Anonymous memory mappings can be shared between processes but only via fork(). But Python 3 supports other ways of starting subprocesses (see issue 8713 [1]) and so an anonymous

[issue30564] Base64 decoding gives incorrect outputs.

2017-06-04 Thread Gareth Rees
Gareth Rees added the comment: RFC 4648 section 3.5 says: The padding step in base 64 and base 32 encoding can, if improperly implemented, lead to non-significant alterations of the encoded data. For example, if the input is only one octet for a base 64 encoding, then all six bits

[issue29977] re.sub stalls forever on an unmatched non-greedy case

2017-04-04 Thread Gareth Rees
Gareth Rees added the comment: See also issue28690, issue212521, issue753711, issue1515829, etc. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue29977] re.sub stalls forever on an unmatched non-greedy case

2017-04-04 Thread Gareth Rees
Gareth Rees added the comment: The problem here is that both "." and "\s" match a whitespace character, and because you have the re.DOTALL flag turned on this includes "\n", and so the number of different ways in which (.|\s)* can be matched against a string

[issue14376] sys.exit documents argument as "integer" but actually requires "subtype of int"

2017-02-02 Thread Gareth Rees
Gareth Rees added the comment: Thank you, Mark (and everyone else who helped). -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue14376] sys.exit documents argument as "integer" but actually requires "subtype of int"

2017-02-01 Thread Gareth Rees
Gareth Rees added the comment: Thanks for the revised patch, Mark. The new tests look good. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue24869] shlex lineno inaccurate with certain inputs

2017-02-01 Thread Gareth Rees
Gareth Rees added the comment: Here's a patch that implements my proposal (1) -- under this patch, tokens read from an input stream belong to a subtype of str with startline and endline attributes giving the line numbers of the first and last character of the token. This allows the accurate

[issue14376] sys.exit documents argument as "integer" but actually requires "subtype of int"

2017-02-01 Thread Gareth Rees
Gareth Rees added the comment: In Windows, under cmd.exe, you can use %errorlevel% -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue14376] sys.exit documents argument as "integer" but actually requires "subtype of int"

2017-02-01 Thread Gareth Rees
Gareth Rees added the comment: Is there any chance of making progress on this issue? Is there anything wrong with my patch? Did I omit any relevant point in my message of 2016-06-11 16:26? It would be nice if this were not left in limbo for another four years

[issue28743] test_choices_algorithms() in test_random uses lots of memory

2016-11-19 Thread Gareth Rees
Gareth Rees added the comment: In order for this to work, the __getitem__ method needs to be: def __getitem__(self, key): if 0 <= key < self.n: return self.elem else: raise IndexError(key) But unfortunately this is very bad for the perfo

[issue28743] test_choices_algorithms() in test_random uses lots of memory

2016-11-19 Thread Gareth Rees
Gareth Rees added the comment: Couldn't the test case use something like this to avoid allocating so much memory? from collections.abc import Sequence class RepeatedSequence(Sequence): """Immutable sequence of n repeats of elem."""

[issue28690] Loop in re (regular expression) processing

2016-11-14 Thread Gareth Rees
Gareth Rees added the comment: This is a well-known gotcha with backtracking regexp implementations. The problem is that in the alternation "( +|'[^']*'|\"[^\"]*\"|[^>]+)" there are some characters (space, apostrophe, double quotes) that match multiple alter

[issue28676] On macOS Sierra, warning: implicit declaration of function 'getentropy'

2016-11-12 Thread Gareth Rees
New submission from Gareth Rees: On macOS Sierra (OSX 10.12.1): $ ./configure --with-pydebug && make [... lots of output omitted ...] gcc -c -Wno-unused-result -Wsign-compare -g -O0 -Wall -Wstrict-prototypes -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno

[issue28647] python --help: -u is misdocumented as binary mode

2016-11-12 Thread Gareth Rees
Gareth Rees added the comment: Here's a patch that copies the text for the -u option from the man page to the --help output. -- keywords: +patch Added file: http://bugs.python.org/file45463/issue28647.patch ___ Python tracker <rep...@bugs.python.

[issue28647] python --help: -u is misdocumented as binary mode

2016-11-12 Thread Gareth Rees
Gareth Rees added the comment: The output of "python3.5 --help" says: -u : unbuffered binary stdout and stderr, stdin always buffered; also PYTHONUNBUFFERED=x see man page for details on internal buffering relating to '-u' If you look at the man page as

[issue27588] Type objects are hashable and comparable for equality but this is not documented

2016-07-22 Thread Gareth Rees
New submission from Gareth Rees: The type objects constructed by the metaclasses in the typing module are hashable and comparable for equality: >>> from typing import * >>> {Mapping[str, int], Mapping[int, str]} {typing.Mapping[int, str], typing.Mapping[str, int]}

[issue24869] shlex lineno inaccurate with certain inputs

2016-06-13 Thread Gareth Rees
Gareth Rees added the comment: A third alternative: 3. Add a method whose effect is to consume comments and whitespace, but which does not yield a token. You could then call this method, and then look at shlex.lineno, which will be the line number of the first character of the next token

[issue24869] shlex lineno inaccurate with certain inputs

2016-06-13 Thread Gareth Rees
Gareth Rees added the comment: Just to restate the problem: The use case is that when emitting an error message for a token, we want to include the number of the line containing the token (or the number of the line where the token started, if the token spans multiple lines, as it might

[issue27306] Grammatical Error in Documentation - Tarfile page

2016-06-13 Thread Gareth Rees
Gareth Rees added the comment: Here's a patch improving the grammar in the tarfile documentation. -- keywords: +patch nosy: +Gareth.Rees Added file: http://bugs.python.org/file43375/issue27306.patch ___ Python tracker <rep...@bugs.python.org>

[issue20508] IndexError from ipaddress._BaseNetwork.__getitem__ has no message

2016-06-11 Thread Gareth Rees
Gareth Rees added the comment: Thank you for applying this patch. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20508> ___ ___

[issue14376] sys.exit documents argument as "integer" but actually requires "subtype of int"

2016-06-11 Thread Gareth Rees
Gareth Rees added the comment: Let's not allow the perfect to be the enemy of the good here. The issue I reported is a very specific one: in Python 2.7, if you pass a long to sys.exit, then the value of the long is not used as the exit code. This is bad because functions like os.spawnv

[issue20508] IndexError from ipaddress._BaseNetwork.__getitem__ has no message

2016-06-11 Thread Gareth Rees
Gareth Rees added the comment: I've attached a revised patch that addresses Berker Peksag's concerns: 1. The message associated with the IndexError is now "address out of range" with no information about which address failed or why. 2. There's a new test case for an IndexError fr

[issue24460] urlencode() of dictionary not as expected

2015-06-17 Thread Gareth Rees
Gareth Rees added the comment: If you read the documentation for urllib.parse.urlencode [1], you'll see that it says: The value element in itself can be a sequence and in that case, if the optional parameter doseq is evaluates to True, individual key=value pairs separated

[issue24405] Missing code markup in Expressions documentation

2015-06-08 Thread Gareth Rees
New submission from Gareth Rees: The Expressions documentation contains the text: * Sets and frozensets define comparison operators to mean subset and superset tests. Those relations do not define total orderings (the two sets ``{1,2}`` and {2,3} are not equal, nor subsets of one another

[issue24406] Built-in Types documentation doesn't explain how dictionaries are compared for equality

2015-06-08 Thread Gareth Rees
Changes by Gareth Rees g...@garethrees.org: -- title: Bulit-in Types documentation doesn't explain how dictionaries are compared for equality - Built-in Types documentation doesn't explain how dictionaries are compared for equality ___ Python

[issue24067] Weakproxy is an instance of collections.Iterator

2015-04-28 Thread Gareth Rees
Gareth Rees added the comment: The documentation says that weakref.Proxy objects are not hashable because this avoids a number of problems related to their fundamentally mutable nature, and prevent their use as dictionary keys. Hashable objects must be immutable, otherwise the hash might

[issue24067] Weakproxy is an instance of collections.Iterator

2015-04-28 Thread Gareth Rees
Gareth Rees added the comment: I don't see any reason for proxy objects to be less hashable than ref objects. The difference is that unlike a ref object, a proxy object is supposed to forward its method calls to the proxied object. So consider what happens if you forward the __hash__ method

[issue24067] Weakproxy is an instance of collections.Iterator

2015-04-28 Thread Gareth Rees
Gareth Rees added the comment: Hashable is particularly misleading, because weakref.Proxy objects are not hashable regardless of the referent. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24067

[issue24067] Weakproxy is an instance of collections.Iterator

2015-04-28 Thread Gareth Rees
Gareth Rees added the comment: Not just Iterator, but Container, Hashable, Iterable, and Sized too! import weakref class C: pass o = C() w = weakref.proxy(o) from collections.abc import * isinstance(w, Container) True isinstance(w, Hashable) True

[issue20606] Operator Documentation Example doesn't work

2015-01-04 Thread Gareth Rees
Gareth Rees added the comment: This is a duplicate of #22180, which was fixed in changeset 9c250f34bfa3 by Raymond Hettinger in branch '3.4'. The fix just removes the bad example, as in my patch. So I suggest that this issue be closed as a duplicate

[issue20941] pytime.c:184 and pytime.c:218: runtime error, outside the range of representable values of type 'long'

2014-03-16 Thread Gareth Rees
Gareth Rees added the comment: How did you get this warning? This looks like runtime output from a program built using Clang/LLVM with -fsanitize=undefined. See here: http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation Signed integer overflow is undefined behaviour, so

[issue20905] Adapt heapq push/pop/replace to allow passing a comparator.

2014-03-13 Thread Gareth Rees
Gareth Rees added the comment: It would be better to accept a key function instead of a comparison function (cf. heapq.nlargest and heapq.nsmallest). But note that this has been proposed before and rejected: see issue1904 where Raymond Hettinger provides this rationale: Use cases aside

[issue20774] collections.deque should ship with a stdlib json serializer

2014-02-26 Thread Gareth Rees
Gareth Rees added the comment: The JSON implementation uses these tests to determine how to serialize a Python object: isinstance(o, (list, tuple)) isinstance(o, dict) So any subclasses of list and tuple are serialized as a list, and any subclass of dict is serialized as an object

[issue20727] Improved roundrobin itertools recipe

2014-02-25 Thread Gareth Rees
Gareth Rees added the comment: If 100 doesn't work for you, try a larger number. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20727

[issue20727] Improved roundrobin itertools recipe

2014-02-25 Thread Gareth Rees
Gareth Rees added the comment: I suspect I messed up the timing I did yesterday, because today I find that 100 isn't large enough, but here's what I found today (in Python 3.3): from timeit import timeit test = [tuple(range(300))] + [()] * 100 timeit(lambda:list(roundrobin1

[issue20727] Improved roundrobin itertools recipe

2014-02-25 Thread Gareth Rees
Gareth Rees added the comment: But now that I look at the code more carefully, the old recipe also has O(n^2) behaviour, because cycle(islice(nexts, pending)) costs O(n) and is called O(n) times. To have worst-case O(n) behaviour, you'd need something like this: from collections import

[issue20727] Improved roundrobin itertools recipe

2014-02-24 Thread Gareth Rees
Gareth Rees added the comment: benchmarks show it to be more than twice as fast I'm sure they do, but other benchmarks show it to be more than twice as slow. Try something like: iterables = [range(100)] + [()] * 100 -- nosy: +Gareth.Rees

[issue12691] tokenize.untokenize is broken

2014-02-18 Thread Gareth Rees
Gareth Rees added the comment: Thanks for your work on this, Terry. I apologise for the complexity of my original report, and will try not to do it again. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12691

[issue19363] Python 2.7's future_builtins.map is not compatible with Python 3's map

2014-02-17 Thread Gareth Rees
Gareth Rees added the comment: Sorry about that; here it is. I had second thoughts about recommending zip() as an alternative (that would only work for cases where the None was constant; in other cases you might need lambda *args: args, but this seemed too complicated), so the note now says

[issue20606] Operator Documentation Example doesn't work

2014-02-12 Thread Gareth Rees
Gareth Rees added the comment: The failing example is: d = {} keys = range(256) vals = map(chr, keys) map(operator.setitem, [d]*len(keys), keys, vals) which works in Python 2 where map returns a list, but not in Python 3 where map returns an iterator. Doc/library

[issue20606] Operator Documentation Example doesn't work

2014-02-12 Thread Gareth Rees
Changes by Gareth Rees g...@garethrees.org: -- keywords: +patch Added file: http://bugs.python.org/file34059/operator.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20606

[issue20539] math.factorial may throw OverflowError

2014-02-07 Thread Gareth Rees
Gareth Rees added the comment: It's not a case of internal storage overflowing. The error is from Modules/mathmodule.c:1426 and it's the input 10**19 that's too large to convert to a C long. You get the same kind of error in other places where PyLong_AsLong or PyLong_AsInt is called on a user

[issue12691] tokenize.untokenize is broken

2014-02-06 Thread Gareth Rees
Gareth Rees added the comment: I did some research on the cause of this issue. The assertion was added in this change by Jeremy Hylton in August 2006: https://mail.python.org/pipermail/python-checkins/2006-August/055812.html (The corresponding Mercurial commit is here: http://hg.python.org

[issue12691] tokenize.untokenize is broken

2014-02-05 Thread Gareth Rees
Changes by Gareth Rees g...@garethrees.org: -- assignee: - docs@python components: +Documentation, Tests nosy: +docs@python ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12691

[issue12691] tokenize.untokenize is broken

2014-02-05 Thread Gareth Rees
Changes by Gareth Rees g...@garethrees.org: Removed file: http://bugs.python.org/file33919/Issue12691.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12691

[issue20507] TypeError from str.join has no message

2014-02-04 Thread Gareth Rees
New submission from Gareth Rees: If you pass an object of the wrong type to str.join, Python raises a TypeError with no error message: Python 3.4.0b3 (default, Jan 27 2014, 02:26:41) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin Type help, copyright, credits

[issue20508] IndexError from ipaddress._BaseNetwork.__getitem__ has no message

2014-02-04 Thread Gareth Rees
New submission from Gareth Rees: If you try to look up an out-of-range address from an object returned by ipaddress.ip_network, then ipaddress._BaseNetwork.__getitem__ raises an IndexError with no message: Python 3.4.0b3 (default, Jan 27 2014, 02:26:41) [GCC 4.2.1 Compatible Apple LLVM

[issue20508] IndexError from ipaddress._BaseNetwork.__getitem__ has no message

2014-02-04 Thread Gareth Rees
Changes by Gareth Rees g...@garethrees.org: -- type: behavior - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20508 ___ ___ Python

[issue19362] Documentation for len() fails to mention that it works on sets

2014-02-04 Thread Gareth Rees
Gareth Rees added the comment: Here's a revised patch using Ezio's suggestion (Return the number of items of a sequence or container). -- Added file: http://bugs.python.org/file33904/len-set.patch ___ Python tracker rep...@bugs.python.org http

[issue19362] Documentation for len() fails to mention that it works on sets

2014-02-04 Thread Gareth Rees
Changes by Gareth Rees g...@garethrees.org: -- title: Documentation for len() fails to mention that it works on sets - Documentation for len() fails to mention that it works on sets versions: +Python 3.4 ___ Python tracker rep...@bugs.python.org

[issue14376] sys.exit documents argument as integer but actually requires subtype of int

2014-02-04 Thread Gareth Rees
Gareth Rees added the comment: Patch attached. I added a test case to Lib/test/test_sys.py. -- Added file: http://bugs.python.org/file33906/exit.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14376

[issue20510] Test cases in test_sys don't match the comments

2014-02-04 Thread Gareth Rees
New submission from Gareth Rees: Lib/test/test_sys.py contains test cases with incorrect comments -- or comments with incorrect test cases, if you prefer: # call without argument try: sys.exit(0) except SystemExit as exc: self.assertEqual(exc.code, 0

[issue19363] Python 2.7's future_builtins.map is not compatible with Python 3's map

2014-02-04 Thread Gareth Rees
Gareth Rees added the comment: What about a documentation change instead? The future_builtins chapter http://docs.python.org/2/library/future_builtins.html in the standard library documentation could note the incompatibility. I've attached a patch which adds the following note

[issue20510] Test cases in test_sys don't match the comments

2014-02-04 Thread Gareth Rees
Gareth Rees added the comment: I normally try not to make changes while we're in here for fear of introducing errors! But I guess the test cases are less critical, so I've taken your review comments as a license to submit a revised patch that: * incorporates your suggestion to use

[issue19362] Documentation for len() fails to mention that it works on sets

2014-02-04 Thread Gareth Rees
Gareth Rees added the comment: Here's a revised patch for Terry (Return the number of items of a sequence or collection.) -- Added file: http://bugs.python.org/file33916/len-set.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org

[issue12691] tokenize.untokenize is broken

2014-02-04 Thread Gareth Rees
Gareth Rees added the comment: Yury, let me see if I can move this issue forward. I clearly haven't done a good job of explaining these problems, how they are related, and why it makes sense to solve them together, so let me have a go now. 1. tokenize.untokenize() raises AssertionError if you

[issue12691] tokenize.untokenize is broken

2014-02-04 Thread Gareth Rees
Changes by Gareth Rees g...@garethrees.org: -- nosy: +benjamin.peterson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12691 ___ ___ Python-bugs

[issue19362] Documentation for len() fails to mention that it works on sets

2013-10-23 Thread Gareth Rees
New submission from Gareth Rees: The help text for the len() built-in function says: Return the number of items of a sequence or mapping. This omits to mention that len() works on sets too. I suggest this be changed to: Return the number of items of a sequence, mapping, or set

[issue19363] Python 2.7's future_builtins.map is not compatible with Python 3's map

2013-10-23 Thread Gareth Rees
New submission from Gareth Rees: In Python 2.7, future_builtins.map accepts None as its first (function) argument: Python 2.7.5 (default, Aug 1 2013, 01:01:17) from future_builtins import map list(map(None, range(3), 'ABC')) [(0, 'A'), (1, 'B'), (2, 'C')] But in Python 3.x

[issue19362] Documentation for len() fails to mention that it works on sets

2013-10-23 Thread Gareth Rees
Gareth Rees added the comment: I considered suggesting container, but the problem is that container is used elsewhere to mean object supporting the 'in' operator (in particular, collections.abc.Container has a __contains__ method but no __len__ method). The abstract base class for object

[issue14376] sys.exit documents argument as integer but actually requires subtype of int

2012-03-21 Thread Gareth Rees
Gareth Rees g...@garethrees.org added the comment: Wouldn't you also have to deal with possible errors from the PyInt_AsLong call? Good point. But I note that Python 3 just does exitcode = (int)PyLong_AsLong(value); so maybe it's not important to do error handling here

[issue14376] sys.exit documents argument as integer but actually requires subtype of int

2012-03-20 Thread Gareth Rees
New submission from Gareth Rees g...@garethrees.org: The documentation for sys.exit says, The optional argument arg can be an integer giving the exit status (defaulting to zero), or another type of object. However, the arguments that are treated as exit statuses are actually subtypes of int

[issue12700] test_faulthandler fails on Mac OS X Lion

2011-08-08 Thread Gareth Rees
Gareth Rees g...@garethrees.org added the comment: After changing NULL to (int *)1, all tests pass. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12700

[issue12700] test_faulthandler fails on Mac OS X Lion

2011-08-08 Thread Gareth Rees
Gareth Rees g...@garethrees.org added the comment: All tests now pass. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12700 ___ ___ Python-bugs

[issue12691] tokenize.untokenize is broken

2011-08-05 Thread Gareth Rees
Gareth Rees g...@garethrees.org added the comment: I think I can make these changes independently and issue two patches, one fixing the problems with untokenize listed here, and another improving tokenize. I've just noticed a third bug in untokenize: in full mode, it doesn't handle backslash

  1   2   >