Hello,
A little mail to signal a possible memory leak in an example of the doc,
not very probable, but it may happen sometimes (and more often if we're
already low on memory):
https://docs.python.org/2/extending/newtypes.html
in:
self->first = PyString_FromString("");
if (self->first == NULL) {
Py_DECREF(self);
return NULL;
}
self->last = PyString_FromString("");
if (self->last == NULL) {
Py_DECREF(self);
return NULL;
}
I think it should be (add line in bold):
self->first = PyString_FromString("");
if (self->first == NULL) {
Py_DECREF(self);
return NULL;
}
self->last = PyString_FromString("");
if (self->last == NULL) {
*Py_DECREF(self->first); /* self->first is != NULL if we get
here. */*
Py_DECREF(self);
return NULL;
}
Best Regards,
Joel Stienlet
New submission from jason <peter.waynechina(a)gmail.com>:
in multiprocessing doc https://docs.python.org/3.6/library/multiprocessing.html
under 17.2.2.7.2. Using a remote manager,
>>> from multiprocessing.managers import BaseManager
>>> import queue
>>> queue = queue.Queue()
>>> class QueueManager(BaseManager): pass
>>> QueueManager.register('get_queue', callable=lambda:queue)
>>> m = QueueManager(address=('', 50000), authkey=b'abracadabra')
>>> s = m.get_server()
>>> s.serve_forever()
queue is used as both module name and variable name, should this be avoided?
----------
assignee: docs@python
components: Documentation
messages: 306389
nosy: 1a1a11a, docs@python
priority: normal
severity: normal
status: open
title: Possible issue in multiprocessing doc
type: enhancement
versions: Python 3.6
_______________________________________
Python tracker <report(a)bugs.python.org>
<https://bugs.python.org/issue32051>
_______________________________________
New submission from Charles Bouchard-Légaré:
The real issue here is that this is not documented in Doc/library/typing.rst.
----------
assignee: docs@python
components: Documentation
messages: 289985
nosy: Charles Bouchard-Légaré, docs@python
priority: normal
severity: normal
status: open
title: typing.Text not available in python 3.5.1
versions: Python 3.5
_______________________________________
Python tracker <report(a)bugs.python.org>
<http://bugs.python.org/issue29879>
_______________________________________
New submission from Cristian Barbarosie:
In the Regular Expression HOWTO
https://docs.python.org/3.6/howto/regex.html#regex-howto
the last example in the "Grouping" section has a bug. The code is supposed to find repeated words, but it catches false repetitions.
>>> p = re.compile(r'(\b\w+)\s+\1')
>>> p.search('Paris in the the spring').group()
'the the'
>>> p.search('k is the thermal coefficient').group()
'the the'
I propose adding a \b after \1, this solves the problem :
>>> p = re.compile(r'(\b\w+)\s+\1\b')
>>> p.search('Paris in the the spring').group()
'the the'
>>> print p.search('k is the thermal coefficient')
None
----------
assignee: docs@python
components: Documentation
messages: 291209
nosy: Cristian Barbarosie, docs@python
priority: normal
severity: normal
status: open
title: in regex-howto, improve example on grouping
type: enhancement
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7
_______________________________________
Python tracker <report(a)bugs.python.org>
<http://bugs.python.org/issue30004>
_______________________________________
New submission from Toby Berla <toby.berla(a)gmail.com>:
in https://docs.python.org/3/tutorial/datastructures.html:
-----
5.5. Dictionaries
...
Here is a small example using a dictionary:
>>>
>>> tel = {'jack': 4098, 'sape': 4139}
>>> tel['guido'] = 4127
>>> tel
{'sape': 4139, 'guido': 4127, 'jack': 4098}
-----
I think the order of dictionary elements shown after 'guido' is inserted is wrong.
The correct order is:
{'jack': 4098, 'sape': 4139, 'guido': 4127}
----------
assignee: docs@python
components: Documentation
messages: 306913
nosy: docs@python, tberla
priority: normal
severity: normal
status: open
title: tutorial on dictionaries has error in example
versions: Python 3.6
_______________________________________
Python tracker <report(a)bugs.python.org>
<https://bugs.python.org/issue32127>
_______________________________________
New submission from Decorater:
The way the documentation currently is set up there is no way to know what these functions in the C API actually do or what all the parameters are to call it unless someone source dives into python. Because of this I think making an C API page or a section for the functions like these or similar capabilities would be an Great an huge help to others as well as an example small module using said PyClassMethod* functions.
I will need to look at how far down in python versions that these functions exist for though.
----------
assignee: docs@python
components: Documentation, Extension Modules
messages: 293907
nosy: Decorater, docs@python
priority: normal
severity: normal
status: open
title: Document the PyClassMethod* C API functions.
versions: Python 3.5, Python 3.6, Python 3.7
_______________________________________
Python tracker <report(a)bugs.python.org>
<http://bugs.python.org/issue30396>
_______________________________________
New submission from Terry J. Reedy <tjreedy(a)udel.edu>:
The itertools roundrobin recipe has an outer loop executed a preset number of times. It is currently implemented with two assignments and a while loop.
https://docs.python.org/3/library/itertools.html#itertools-recipes
These can be replaced with a for loop using a reversed range.
def roundrobin(*iterables):
"roundrobin('ABC', 'D', 'EF') --> A D E B F C"
nexts = cycle(iter(it).__next__ for it in iterables)
for current_len in reversed(range(1, len(iterables)+1)):
try:
for next in nexts:
yield next()
except StopIteration:
nexts = cycle(islice(nexts, current_len - 1))
I think this is easier to understand. So do some other participants in the current python-ideas thread 'Rewriting the "roundrobin" recipe in the itertools documentation'.
I changed 'pending' to 'current_len' because, to me, 'pending' should be the set of iter_nexts and not their number.
I originally avoided the '-1' in the islice call by decrementing both range arguments by 1 and calling the loop variable 'reduced_len'. But having the loop variable be the size of the nexts iterable in the next outer iteration seemed confusing and not worth the trivial efficiency gain.
An independent change would be to replace 'next' with 'iter' on the basis that reusing the builtin name is not good and because 'nexts' is awkward to pronounce.
I will produce a PR if any version is preferred to the current one.
---
The OP proposed, and some participants like, an accept-reject algorithm based on zip_longest.
def roundrobin(*iters):
"roundrobin('ABC', 'D', 'EF') --> A D E B F C"
# Perhaps "flat_zip_nofill" is a better name, or something similar
sentinel = object()
for tup in it.zip_longest(*iters, fillvalue=sentinel):
yield from (x for x in tup if x is not sentinel)
I dislike creating tuples we don't want, with values we don't want, with an arbitrarily small acceptance ratio. I also note that zip_longest is properly used in grouper, whereas roundrobin is the only recipe using cycle.
----------
assignee: docs@python
components: Documentation
messages: 306605
nosy: docs@python, rhettinger, terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: Use range in itertools roundrobin recipe
type: enhancement
versions: Python 3.7
_______________________________________
Python tracker <report(a)bugs.python.org>
<https://bugs.python.org/issue32099>
_______________________________________
New submission from Eli_B:
The documentation says isinstance(x, (int, int)) would be fixed to isinstance(x, (int)). The fix is actually isinstance(x, int).
I propose the following text instead:
"
2to3fixer:: isinstance
Fixes duplicate types in the second argument of :func:`isinstance`. For example, isinstance(x, (int, int)) is converted to isinstance(x, int) and isinstance(x, (int, float, int)) is converted to isinstance(x, (int, float)).
"
----------
assignee: docs@python
components: Documentation
files: 2to3.rst
messages: 294351
nosy: Eli_B, docs@python
priority: normal
pull_requests: 1867
severity: normal
status: open
title: 2to3 docs: example of fix for duplicates in second argument of isinstance has superfluous parentheses
versions: Python 2.7
Added file: http://bugs.python.org/file46894/2to3.rst
_______________________________________
Python tracker <report(a)bugs.python.org>
<http://bugs.python.org/issue30456>
_______________________________________