[issue25084] remove semi-busy loop in py2.7 threading.Condition.wait(timeout=x)

2015-09-15 Thread matteo

Changes by matteo :


--
nosy: +matteo

___
Python tracker 
<http://bugs.python.org/issue25084>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3475] _elementtree.c import can fail silently

2008-07-31 Thread Matteo Bertini

New submission from Matteo Bertini <[EMAIL PROTECTED]>:

Playing with PyInstaller I have found that the final part of 
_elementtree.c:

Index: Modules/_elementtree.c
===
--- Modules/_elementtree.c  (revisione 59540)
+++ Modules/_elementtree.c  (copia locale)
@@ -2780,7 +2780,10 @@

   );

-PyRun_String(bootstrap, Py_file_input, g, NULL);
+if (PyRun_String(bootstrap, Py_file_input, g, NULL) == NULL)
+return;

elementpath_obj = PyDict_GetItemString(g, "ElementPath");

execute a bit of python code without checking the return value.
That can lead to weird things playing with import hooks,
for example an assert like this can fail:

Index: Lib/test/test_elemettree.py
===
--- Lib/test/test_elemettree.py (revisione 0)
+++ Lib/test/test_elemettree.py (revisione 0)
@@ -0,0 +1,21 @@
+#! /usr/bin/env python
+
+def importHook(*args, **kwargs):
+if 'xml.etree' in args:
+raise ImportError
+else:
+return __real__import__(*args, **kwargs)
+
+import os
+import __builtin__
+__real__import__ = __builtin__.__import__
+__builtin__.__import__ = importHook
+
+try:
+import xml.etree.cElementTree as cET
+except ImportError:
+pass
+else:
+out = os.popen("python -c 'import xml.etree.cElementTree as cET; 
print dir(cET)'").read().strip()
+assert str(dir(cET)) == out, (str(dir(cET)), out)
+

--
components: XML
messages: 70488
nosy: naufraghi
severity: normal
status: open
title: _elementtree.c import can fail silently
versions: Python 2.5

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3475>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1068268] subprocess is not EINTR-safe

2008-09-05 Thread Matteo Bertini

Matteo Bertini <[EMAIL PROTECTED]> added the comment:

I'd like to suggest to rise the priority of this bug.
Till this bus is around, no way using any module using subprocess.Popen 
form a PyQt app (and I suppose PyGtk and wxPython too).

--
nosy: +naufraghi

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1068268>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1068268] subprocess is not EINTR-safe

2008-09-17 Thread Matteo Bertini

Matteo Bertini <[EMAIL PROTECTED]> added the comment:

Upgrade subprocess.py patch to 25-maint r65475
(apply cleanly with http://bugs.python.org/issue2113 fixed)

--
keywords: +patch
Added file: 
http://bugs.python.org/file11511/subprocess-eintr-safety-25maint-r65475.patch

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1068268>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4017] IDLE 2.6 broken on OSX (Leopard)

2008-10-12 Thread Matteo Bertini

Matteo Bertini <[EMAIL PROTECTED]> added the comment:

I have the same error as in msg74221
RuntimeError: tk.h version (8.4) doesn't match libtk.a version (8.5)

Some workaround not involving a full rebuild?

--
nosy: +naufraghi

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue4017>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1068268] subprocess is not EINTR-safe

2008-10-17 Thread Matteo Bertini

Matteo Bertini <[EMAIL PROTECTED]> added the comment:

Factorized try-except code, merged r65475 from 25-maint.
Protetect std[in|out|err] read and write too.

Added file: 
http://bugs.python.org/file11818/subprocess-retry-on-EINTR-std-in-out-err.diff

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1068268>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1068268] subprocess is not EINTR-safe

2008-10-17 Thread Matteo Bertini

Matteo Bertini <[EMAIL PROTECTED]> added the comment:

Ups, forgot a _no_intr around select.select

Index: subprocess.py
===
--- subprocess.py   (revisione 19645)
+++ subprocess.py   (copia locale)
@@ -1178,7 +1178,7 @@
 
 input_offset = 0
 while read_set or write_set:
-rlist, wlist, xlist = select.select(read_set, 
write_set, [])
+rlist, wlist, xlist = _no_intr(select.select)(read_set, 
write_set, [])
 
 if self.stdin in wlist:
 # When select has indicated that the file is 
writable,

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1068268>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3588] sysconfig variable LINKFORSHARED has wrong value for MacOS X framework build

2008-11-04 Thread Matteo Bertini

Matteo Bertini <[EMAIL PROTECTED]> added the comment:

I confirm this issue, some handy workaround available?

--
nosy: +naufraghi

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3588>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3588] sysconfig variable LINKFORSHARED has wrong value for MacOS X framework build

2008-11-04 Thread Matteo Bertini

Matteo Bertini <[EMAIL PROTECTED]> added the comment:

The solution I found is:

LINKFORSHARED = -u _PyMac_Error -framework Python

as in the Apple included Python Makefile

and

LDFLAGS += -F$(PYTHONFRAMEWORKPREFIX)

that makes linker use the right framework (not sure, but works with
MacPython installed)

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3588>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3588] sysconfig variable LINKFORSHARED has wrong value for MacOS X framework build

2008-11-05 Thread Matteo Bertini

Matteo Bertini <[EMAIL PROTECTED]> added the comment:

I can add that providing the option:

-mmacosx-version-min=10.4

or setting the anv var

MACOSX_DEPLOYMENT_TARGET=10.4

is it possible to build an extension in MacPython.org too
(without that option there was a problem with some 10.5 libs)

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3588>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1068268] subprocess is not EINTR-safe

2008-12-18 Thread Matteo Bertini

Matteo Bertini  added the comment:

Python 2.5.3 is near but the I think the fix in
http://svn.python.org/view?rev=65475&view=rev
is not enough, there are a lot of other places where EINTR can cause and 
error.

--
versions: +Python 2.5.3

___
Python tracker 
<http://bugs.python.org/issue1068268>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1068268] subprocess is not EINTR-safe

2008-12-23 Thread Matteo Bertini

Matteo Bertini  added the comment:

Please have a look at the proposed patch:

http://bugs.python.org/file11511/subprocess-eintr-safety-25maint-
r65475.patch

the list is more or less the patch itself.

___
Python tracker 
<http://bugs.python.org/issue1068268>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1068268] subprocess is not EINTR-safe

2008-12-24 Thread Matteo Bertini

Changes by Matteo Bertini :


Removed file: 
http://bugs.python.org/file11818/subprocess-retry-on-EINTR-std-in-out-err.diff

___
Python tracker 
<http://bugs.python.org/issue1068268>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1068268] subprocess is not EINTR-safe

2008-12-24 Thread Matteo Bertini

Changes by Matteo Bertini :


Removed file: 
http://bugs.python.org/file11511/subprocess-eintr-safety-25maint-r65475.patch

___
Python tracker 
<http://bugs.python.org/issue1068268>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1068268] subprocess is not EINTR-safe

2008-12-24 Thread Matteo Bertini

Matteo Bertini  added the comment:

no EINTR patch upgraded to 25-maint r65475 that protects:

*) all direct calls
*) all returned fd

I hope :P

Added file: 
http://bugs.python.org/file12438/no-EINTR-subprocess.py-25-maint-r65475.patch

___
Python tracker 
<http://bugs.python.org/issue1068268>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38200] Adding itertools.pairwise to the standard library?

2019-09-17 Thread Matteo Dell'Amico


New submission from Matteo Dell'Amico :

I use itertools.pairwise all the time and I wonder if the same happens to 
others. I'm thinking that others may be in the same situation, and having this 
simple recipe already included in the library would be definitely more 
convenient than copy/pasting the recipe. Also, it may improve its visibility...

--
components: Library (Lib)
messages: 352642
nosy: della
priority: normal
severity: normal
status: open
title: Adding itertools.pairwise to the standard library?

___
Python tracker 
<https://bugs.python.org/issue38200>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38200] Adding itertools.pairwise to the standard library?

2019-10-01 Thread Matteo Dell'Amico


Matteo Dell'Amico  added the comment:

Sorry for taking so long to answer, I didn't see notifications somehow.

Raymond, my use case is in general something that happens when I'm doing 
analytics on sequences of events (e.g., URLs visited by a browser) or paths in 
a graph. I look at pairs and do something based on the pair of events (e.g., 
did the user likely clicked an advertising link? did they go to a potentially 
risky webpage, possibly by clicking a link?)

I see the argument for generalizing to a sliding window, although that may lead 
people to choosing inefficient algorithms for sliding average or median.

--

___
Python tracker 
<https://bugs.python.org/issue38200>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43653] Typo in the random.shuffle docs

2021-03-29 Thread Matteo Bertucci


New submission from Matteo Bertucci :

Hello!

The current documentation for random.shuffle reads:
> The optional argument random is a 0-argument function returning a random 
> float in [0.0, 1.0); by default, this is the function random().

I believe the range here should use matching symbols, unless I am missing 
something.

--
assignee: docs@python
components: Documentation
messages: 389669
nosy: Akarys, docs@python
priority: normal
severity: normal
status: open
title: Typo in the random.shuffle docs
type: enhancement

___
Python tracker 
<https://bugs.python.org/issue43653>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43653] Typo in the random.shuffle docs

2021-03-29 Thread Matteo Bertucci


Change by Matteo Bertucci :


--
stage:  -> resolved
status: open -> closed

___
Python tracker 
<https://bugs.python.org/issue43653>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43653] Typo in the random.shuffle docs

2021-03-29 Thread Matteo Bertucci


Matteo Bertucci  added the comment:

Oh I see, I was used to seeing open intervals using ]a, b[. All good then!

--

___
Python tracker 
<https://bugs.python.org/issue43653>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45762] Missing `list` symbols in the object inventory

2021-11-09 Thread Matteo Bertucci


New submission from Matteo Bertucci :

Sphinx generates a quite useful inventory file, listing all the different 
symbols available inside the documentation. You can find the docs.python.org 
inventory over at https://docs.python.org/objects.inv. The syntax of this file 
can be found here https://sphobjinv.readthedocs.io/en/latest/syntax.html.

We use it over at Python Discord to power up our `!docs` command. It allows us 
to look up symbols such as `asyncio.run`, have nicely formatted documentation 
and links to the web page. 

The problem is due to where the `list` method documentations are located, 
inside `/tutorial/datastructures` 
(https://docs.python.org/3/tutorial/datastructures.html), no symbol is exported 
for those, making commands such as `!docs list.append` fail, which is quite a 
bummer. It would be very nice to have access to those.

--
assignee: docs@python
components: Documentation
messages: 406004
nosy: Akarys, docs@python
priority: normal
severity: normal
status: open
title: Missing `list` symbols in the object inventory
versions: Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python 
3.9

___
Python tracker 
<https://bugs.python.org/issue45762>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40439] Error in an external reference

2020-05-18 Thread Matteo Bertucci


Change by Matteo Bertucci :


--
keywords: +patch
nosy: +Akarys
nosy_count: 4.0 -> 5.0
pull_requests: +19485
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/20184

___
Python tracker 
<https://bugs.python.org/issue40439>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42240] Add Maxheap version of a heappush into heapq module

2020-12-04 Thread Matteo Dell'Amico


Matteo Dell'Amico  added the comment:

Personally, I'd find a maxheap in the standard library helpful, and a quick 
Google search tells me I'm not alone.

I generally have to deal with numeric values, so I have these choices:
 - ugly code (e.g., `minus_distance, elem = heappop(heap)`, `distance = 
-minus_distance`)
 - slow code (e.g., wrapping heapq in a class)

Since most of maxheap is already implemented in the library, I wonder what is 
the rationale for not including it.

A couple of use cases for max-heap that I ran into:
 - maintaining k-nearest-neighbor structures (the farthest known one is at the 
top of the queue)
 - running median (requires both a minheap and a maxheap)

--
nosy: +della

___
Python tracker 
<https://bugs.python.org/issue42240>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14156] argparse.FileType for '-' doesn't work for a mode of 'rb'

2017-05-05 Thread Matteo Bertini

Matteo Bertini added the comment:

Bumped in this bug yesterday, sadly a script working (by chance) in Python2 
doesn't work in Python3 because of this bug.

--
nosy: +naufraghi

___
Python tracker 
<http://bugs.python.org/issue14156>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16285] Erroneously encoding tilde to %7e in quote

2012-10-19 Thread Matteo Parrucci

New submission from Matteo Parrucci:

RFC 3986 (http://www.ietf.org/rfc/rfc3986.txt) says:

For consistency, percent-encoded octets in the ranges of ALPHA
(%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), period (%2E),
underscore (%5F), or tilde (%7E) should not be created by URI
producers and, when found in a URI, should be decoded to their
corresponding unreserved characters by URI normalizers.

>From python documentation talking about urllib.quote()

Example: quote('/~connolly/') yields '/%7econnolly/'.

I think ~ should be added to the safe characters of quote function

--
messages: 173319
nosy: Matteo.Parrucci
priority: normal
severity: normal
status: open
title: Erroneously encoding tilde to %7e in quote

___
Python tracker 
<http://bugs.python.org/issue16285>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19185] Allow multiprocessing Pool initializer to return values

2013-10-06 Thread Matteo Cafasso

New submission from Matteo Cafasso:

This patch allows the pool initializer function to return the initialized 
values. The returned values will be passed to the called function as first 
positional argument.

Previously the common pattern was to store the initialized objects into global 
variables making the code more difficult to manage.

The patch is not breaking any backward compatibility as the previous 
initializers were not supposed to return any value, if the initializer does not 
return anything the behavior is the same as usual.

--
files: pool_initializer.patch
keywords: patch
messages: 199116
nosy: noxdafox
priority: normal
severity: normal
status: open
title: Allow multiprocessing Pool initializer to return values
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file31978/pool_initializer.patch

___
Python tracker 
<http://bugs.python.org/issue19185>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19185] Allow multiprocessing Pool initializer to return values

2013-10-06 Thread Matteo Cafasso

Matteo Cafasso added the comment:

I agree with your point, I've probably made my considerations too quickly.

The consideration was based on the fact that returning any value previously was 
a misuse (without consequences) of the initializer itself.

Now the misuse would be exposed by the new implementation, probably meeting the 
requirements that leds to the misuse itself.

Aim of the patch is to give an alternative to the use of global variables.
Global variables usage is a pattern which might lead to code errors and many 
developers discourage from following it.
I do believe that forcing such pattern in order to accomplish the desired goals 
is quite restrictive from an API.

--

___
Python tracker 
<http://bugs.python.org/issue19185>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19185] Allow multiprocessing Pool initializer to return values

2013-10-09 Thread Matteo Cafasso

Matteo Cafasso added the comment:

On 07/10/13 13:32, Richard Oudkerk wrote:
> Richard Oudkerk added the comment:
>
> I think "misuse" is an exageration.  Various functions change some state and 
> return a value that is usually ignored, e.g. os.umask(), signal.signal().
These functions are compliant with POSIX standards and the return values 
are actually useful, they return the previously set masks and handlers, 
often are ignored but in complex cases it's good to know their previous 
state.

The problem here is quite different, the interface is giving the 
opportunity of executing a function but it ignores the returned values, 
this is pretty limiting from an API point of view. It is quite 
counterintuitive and also not documented, proof is the amount of 
questions on how to use the initializer (just a couple of examples):
http://stackoverflow.com/questions/10117073/how-to-use-initializer-to-set-up-my-multiprocess-pool
http://stackoverflow.com/questions/9944370/use-of-initialize-in-python-multiprocessing-worker-pool
>
>> Global variables usage is a pattern which might lead to code errors and many
>> developers discourage from following it.
> What sort of code errors?  This really seems a stylistic point.  Maybe such 
> developers would be happier using class methods and class variables rather 
> than functions and globals variables.
http://c2.com/cgi/wiki?GlobalVariablesAreBad

It is a pretty common code practice to avoid global variables whenever 
possible; as always: is the way a tool is used to make it evil not the 
tool itself; yet I agree with the fact that a global variable change is 
hard to track down into the code and when the code grows it can lead to 
very tricky errors.
>
> Out of interest, what do you usually do in your initializer functions?
I mainly develop back-end systems which take great advantage from the 
Worker Pool pattern. We are talking about services which uses third 
party libraries to execute CPU bounded tasks trying to scale up with the 
number of CPU cores. Many of these libraries, unfortunately, are 
stateful (I would say "state-full") and their initialization is 
time-consuming.

Typically a worker initializes some of those objects (which currently 
are stored in global variables) and starts crunching some data, 
meanwhile the state of these objects keeps changing and here the global 
variables pattern shows its worst side.

>
> --
>
> ___
> Python tracker 
> <http://bugs.python.org/issue19185>
> ___

--

___
Python tracker 
<http://bugs.python.org/issue19185>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19185] Allow multiprocessing Pool initializer to return values

2013-10-21 Thread Matteo Cafasso

Matteo Cafasso added the comment:

On 09/10/13 22:59, Richard Oudkerk wrote:
> Yes.  But my point was that somebody might have used such a function as the 
> initializer argument.  The proposed change would break a program which does
>
>  with Pool(initializer=os.nice, initargs=(incr,)) as p:
>  ...
Indeed in cases like that the backward compatibility would break if the 
passed function is accepting a fixed amount of positional arguments.

--

___
Python tracker 
<http://bugs.python.org/issue19185>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7111] core dump when stderr is moved

2009-10-24 Thread Matteo Bertini

Changes by Matteo Bertini :


--
nosy: +naufraghi

___
Python tracker 
<http://bugs.python.org/issue7111>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7111] stdout closed

2009-10-24 Thread Matteo Bertini

Changes by Matteo Bertini :


--
title: core dump when stderr is moved -> stdout closed

___
Python tracker 
<http://bugs.python.org/issue7111>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7111] core dump when stderr is moved

2009-10-24 Thread Matteo Bertini

Matteo Bertini  added the comment:

sorry, title restored!

--
title: stdout closed -> core dump when stderr is moved

___
Python tracker 
<http://bugs.python.org/issue7111>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1488934] file.write + closed pipe = no error

2009-10-24 Thread Matteo Bertini

Changes by Matteo Bertini :


--
nosy: +naufraghi
type:  -> behavior

___
Python tracker 
<http://bugs.python.org/issue1488934>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1596] Broken pipes should be handled better in 2.x

2009-10-24 Thread Matteo Bertini

Changes by Matteo Bertini :


--
nosy: +naufraghi

___
Python tracker 
<http://bugs.python.org/issue1596>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5350] Modification to "pairwise" in itertools recipes

2009-02-23 Thread Matteo Dell'Amico

New submission from Matteo Dell'Amico :

I feel that the "pairwise" recipe could be slightly more elegant if "for
elem in b: break" became a simpler next(b) (or b.next() for Python 2.x).
It is also more natural to modify the recipes to suit one's needs (e.g.,
returning items with a given gap between them, or convert the recipe to
k-wise iteration).

--
assignee: georg.brandl
components: Documentation
messages: 82626
nosy: della, georg.brandl
severity: normal
status: open
title: Modification to "pairwise" in itertools recipes

___
Python tracker 
<http://bugs.python.org/issue5350>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5350] Modification to "pairwise" in itertools recipes

2009-02-23 Thread Matteo Dell'Amico

Matteo Dell'Amico  added the comment:

Georg, you're right, there's a StopIteration to catch. My thinko was
mistaking the function for a generator where the exception propagation
would have done the right thing. The amended version now becomes

next(b)
for x, y in zip(a, b): yield x, y

...which is not that attractive anymore, also because it's slower. Sorry
for the error.

___
Python tracker 
<http://bugs.python.org/issue5350>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5352] Missing 'non overlapping' clause in str.count documentation

2009-02-23 Thread Matteo Dell'Amico

New submission from Matteo Dell'Amico :

The str.count (http://docs.python.org/dev/py3k/library/stdtypes.html)
documentation does not report that it returns the number of
*non-overlapping* instances. For example, I expected 'aaa'.count('aa')
to be 2 and not 1. Compare this with the string module documentation,
where the non-overlapping clause is reported.

--
assignee: georg.brandl
components: Documentation
messages: 82632
nosy: della, georg.brandl
severity: normal
status: open
title: Missing 'non overlapping' clause in str.count documentation

___
Python tracker 
<http://bugs.python.org/issue5352>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5350] Modification to "pairwise" in itertools recipes

2009-02-23 Thread Matteo Dell'Amico

Matteo Dell'Amico  added the comment:

great Raymond! :)

___
Python tracker 
<http://bugs.python.org/issue5350>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5647] MutableSet.__iand__ implementation calls self.discard while iterating on self

2009-04-01 Thread Matteo Dell'Amico

New submission from Matteo Dell'Amico :

The current MutableSet.__iand__ implementation calls self.discard while
iterating on self. This creates strange problems while implementing
MutableSet with simple choices. For example, consider the attached file
which implements set by delegating either to a set or a list. In the
first cases, an exception is raised; in the second, the result is not
what is expected.

Python 2.6+ (r26:66714, Oct 22 2008, 09:21:39) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from simpleset import WithSet, WithList
>>> s = WithSet([1,2])
>>> s &= ()
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.6/_abcoll.py", line 290, in __iand__
for value in self:
RuntimeError: Set changed size during iteration
>>> s = WithList([1,2])
>>> s &= ()
>>> list(s)
[2]

--
components: Library (Lib)
files: simpleset.py
messages: 85006
nosy: della
severity: normal
status: open
title: MutableSet.__iand__ implementation calls self.discard while iterating on 
self
versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1
Added file: http://bugs.python.org/file13538/simpleset.py

___
Python tracker 
<http://bugs.python.org/issue5647>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5647] MutableSet.__iand__ implementation calls self.discard while iterating on self

2009-04-01 Thread Matteo Dell'Amico

Matteo Dell'Amico  added the comment:

I suggest solving the problem by changing the implementation to:

def __iand__(self, c):
self -= self - c:

or to

def __iand__(self, c):
for item in self - c:
self.discard(item)

--

___
Python tracker 
<http://bugs.python.org/issue5647>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5779] _elementtree import can fail silently

2009-04-17 Thread Matteo Bertini

New submission from Matteo Bertini :

(the patch is old, I forwarded it to Fredrik but I forgot to open the bug)

Playing with PyInstaller I have found that the final part of _elementtree.c:

Index: Modules/_elementtree.c
===
--- Modules/_elementtree.c  (revisione 59540)
+++ Modules/_elementtree.c  (copia locale)
@@ -2780,7 +2780,10 @@

);

-PyRun_String(bootstrap, Py_file_input, g, NULL);
+if (PyRun_String(bootstrap, Py_file_input, g, NULL) == NULL) {
+m = PyErr_Occurred();
+return;
+}

 elementpath_obj = PyDict_GetItemString(g, "ElementPath");

executes a bit of python code without checking the return value.
That can lead to weird things playing with import hooks,
for example an assert like this can fail:

Index: Lib/test/test_elemettree.py
===
--- Lib/test/test_elemettree.py (revisione 0)
+++ Lib/test/test_elemettree.py (revisione 0)
@@ -0,0 +1,21 @@
+#! /usr/bin/env python
+
+def importHook(*args, **kwargs):
+if 'xml.etree' in args:
+raise ImportError
+else:
+return __real__import__(*args, **kwargs)
+
+import os
+import __builtin__
+__real__import__ = __builtin__.__import__
+__builtin__.__import__ = importHook
+
+try:
+import xml.etree.cElementTree as cET
+except ImportError:
+pass
+else:
+out = os.popen("python -c 'import xml.etree.cElementTree as cET;
print dir(cET)'").read().strip()
+assert str(dir(cET)) == out, (str(dir(cET)), out)
+

Quite a novice with python internals, so comments are welcome.
Matteo Bertini

--
components: XML
messages: 86062
nosy: naufraghi
severity: normal
status: open
title: _elementtree import can fail silently

___
Python tracker 
<http://bugs.python.org/issue5779>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5779] _elementtree import can fail silently

2009-04-17 Thread Matteo Bertini

Matteo Bertini  added the comment:

Ups, I duplicated myself... issue3475

--
status: open -> closed

___
Python tracker 
<http://bugs.python.org/issue5779>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5867] No way to create an abstract classmethod

2009-04-28 Thread Matteo Dell'Amico

New submission from Matteo Dell'Amico :

Is there a way to define an abstract classmethod? The two obvious ways
don't seem to work properly.

Python 3.0.1+ (r301:69556, Apr 15 2009, 17:25:52) 
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import abc
>>> class C(metaclass=abc.ABCMeta):
... @abc.abstractmethod
... @classmethod
... def f(cls): print(42)
... 
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 3, in C
  File "/usr/lib/python3.0/abc.py", line 24, in abstractmethod
funcobj.__isabstractmethod__ = True
AttributeError: 'classmethod' object has no attribute '__isabstractmethod__'
>>> class C(metaclass=abc.ABCMeta):
... @classmethod
... @abc.abstractmethod
... def f(cls): print(42)
... 
>>> class D(C): pass
... 
>>> D.f()
42

--
components: Library (Lib)
messages: 86744
nosy: della
severity: normal
status: open
title: No way to create an abstract classmethod
type: behavior
versions: Python 3.0

___
Python tracker 
<http://bugs.python.org/issue5867>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9031] distutils uses invalid "-Wstrict-prototypes" flag when compiling C++ extension module

2010-06-18 Thread Matteo Vescovi

New submission from Matteo Vescovi :

Hi,

It seems like distutils passes an invalid "-Wstrict-prototypes" flag when 
compiling a C++ extension module on Linux (tested on Debian lenny and sid).

running build
running build_py
creating build
creating build/lib.linux-i686-2.6
copying presage.py -> build/lib.linux-i686-2.6
running build_ext
building '_presage' extension
creating build/temp.linux-i686-2.6
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall 
-Wstrict-prototypes -g -O2 -g -Wall -O2 -fPIC -I../../src/lib 
-I/usr/include/python2.6 -c presage_wrap.cpp -o 
build/temp.linux-i686-2.6/presage_wrap.o
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for 
Ada/C/ObjC but not for C++
g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -L/usr/local/lib 
-Wl,--as-needed -g -O2 -g -Wall -O2 build/temp.linux-i686-2.6/presage_wrap.o 
-L../../src/lib/.libs -lpresage -o build/lib.linux-i686-2.6/_presage.so
running build_scripts
creating build/scripts-2.6
copying and adjusting presage_python_demo -> build/scripts-2.6
changing mode of build/scripts-2.6/presage_python_demo from 644 to 755

I did a bit of digging on this one. It looks like distutils reuses whatever 
flags python was built with.

m...@burrow:/usr/lib/python2.5/distutils$ python2.5
Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> sysconfig.get_config_var("CFLAGS")
'-fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes'
>>>

In /usr/lib/python2.5/distutils/unixcompiler.py I found this comment:

# XXX Things not currently handled:
#   * optimization/debug/warning flags; we just use whatever's in Python's
# Makefile and live with it.  Is this adequate?  If not, we might
# have to have a bunch of subclasses GNUCCompiler, SGICCompiler,
# SunCCompiler, and I suspect down that road lies madness.


It would be nice is distutils was smart enough to recognize that a c++ module 
was being built and to strip the unneeded flags.

Please consider this as a wishlist request, as this causes only a warning, not 
a failure.


Cheers,
- Matteo

--
assignee: tarek
components: Distutils
messages: 108136
nosy: matteo.vescovi, tarek
priority: normal
severity: normal
status: open
title: distutils uses invalid "-Wstrict-prototypes" flag when compiling C++ 
extension module
type: feature request
versions: Python 2.5, Python 2.6

___
Python tracker 
<http://bugs.python.org/issue9031>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23246] distutils fails to locate vcvarsall with Visual C++ Compiler for Python

2016-12-15 Thread Matteo Bertini

Matteo Bertini added the comment:

I'm back on this issue with a minimal patch, and a longer motivation.

Distutils does not support Visual C++ for Python compiler, but it could, with a 
one-line patch.

The proposed workaround is to use `setuptools`. But, we are not alone in this 
World, am I supposed to fork each third party package still using `distutils` 
and upgrade them to `setuptools`?

No, someone will say, you can "simply" `import setuptools`, and it will 
monkey-patch `distutils` adding the support for VS for Python.

1) this is implicit, very very against the Python Zen
2) the modifications are not limited and back-compatible. Some packages, say 
`sip` from `PyQt`, are broken simply adding this `import setuptools`, and other 
are too.

That said, I think this minimal patch to the `find_vcvarsall` code, can save a 
lot of time to every Python 2.7 users, time I see better spent upgrading to 
Python 3.

Sorry for the rant-mode, but I very liked Python, and I still like Python more 
than other languages, but I don't think that providing half broken solutions 
and very limited support to all the developer still running Python 2.7 in some 
big old project is a good strategy to push people to Python 3.

Python 3 is already a better language, but Python as a language can be a better 
language only if Python 2.7 will be a first class citizen till 2020.

--
keywords: +patch
nosy: +naufraghi
type:  -> enhancement
Added file: http://bugs.python.org/file45916/vsforpython.diff

___
Python tracker 
<http://bugs.python.org/issue23246>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29039] Segmentation fault when using PyUnicode_FromString

2016-12-21 Thread Matteo Cafasso

New submission from Matteo Cafasso:

The following code snippet:

--
#include 
#include 

int main()
{
char *broken_string[8];
char broken_char = 4294967252;

sprintf(broken_string, "%c", broken_char);

PyUnicode_FromString(broken_string);
}
--

Produces a Segmentation Fault.

Is this behaviour the expected one? 

The real life example comes when reading a malformed path on a Ext4 filesystem. 
The read string causes PyUnicode_FromString to segfault.

--
components: Extension Modules
messages: 283777
nosy: noxdafox
priority: normal
severity: normal
status: open
title: Segmentation fault when using PyUnicode_FromString
type: crash
versions: Python 3.5

___
Python tracker 
<http://bugs.python.org/issue29039>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24068] statistics module - incorrect results with boolean input

2015-05-20 Thread Matteo Dell'Amico

Changes by Matteo Dell'Amico :


--
nosy: +della

___
Python tracker 
<http://bugs.python.org/issue24068>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39603] [security] http.client: HTTP Header Injection in the HTTP method

2020-09-28 Thread Mauro Matteo Cascella


Mauro Matteo Cascella  added the comment:

Hello,

CVE-2020-26116 has been requested/assigned for this flaw via MITRE form: 
https://cveform.mitre.org/

I suggest mentioning it in the related vulnerability page: 
https://python-security.readthedocs.io/vuln/http-header-injection-method.html

Also note that httplib (python-2.7.18) seems to be affected too. Any particular 
reason for it not to be listed in the same vulnerability page?

Thank you,

--
nosy: +mcascella

___
Python tracker 
<https://bugs.python.org/issue39603>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com