[issue27181] Add geometric mean to `statistics` module

2016-07-08 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I would like to see them spelled-out:  geometric_mean and harmonic_mean

--

___
Python tracker 

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



[issue27181] Add geometric mean to `statistics` module

2016-07-08 Thread Steven D'Aprano

Steven D'Aprano added the comment:

Does anyone have any strong feeling about the name for these functions?

gmean and hmean;

geometric_mean and harmonic_mean

And "subcontrary_mean" is not an option :-)

--

___
Python tracker 

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



[issue27471] sre_constants.error: bad escape \d

2016-07-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

It is a deprection warning in 3.5.

$ python3.5 -Wd
>>> import re
>>> re.sub(re.escape(r'(\d+?)'), '(?:\d+?)', r'(\d+?)')
/usr/lib/python3.5/re.py:182: DeprecationWarning: bad escape \d
  return _compile(pattern, flags).sub(repl, string, count)
'(?:\\d+?)'

The warning was added in issue23622, and turned into exception in issue27030.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue6721] Locks in the standard library should be sanitized on fork

2016-07-08 Thread Connor Wolf

Connor Wolf added the comment:

> Python 3.5.1+ (default, Mar 30 2016, 22:46:26)

Whatever the stock 3.5 on ubuntu 16.04 x64 is.

I've actually been running into a whole horde of really bizarre issues related 
to what I /think/ is locking in stdout. 

Basically, I have a context where I have thousands and thousands of (relatively 
short lived) `multiprocessing.Process()` processes, and over time they all get 
wedged (basically, I have ~4-32 processes alive at any time, but they all get 
recycled every few minutes).

After doing some horrible 
(https://github.com/fake-name/ReadableWebProxy/blob/master/logSetup.py#L21-L78) 
hackery in the logging module, I'm not seeing processes get wedged there, but I 
do still encounter issues with what I can only assume is a lock in the print 
statement. I'm hooking into a wedged process using 
[pystuck](https://github.com/alonho/pystuck)

durr@rwpscrape:/media/Storage/Scripts/ReadableWebProxy⟫ pystuck --port 6675
Welcome to the pystuck interactive shell.
Use the 'modules' dictionary to access remote modules (like 'os', or '__main__')
Use the `%show threads` magic to display all thread stack traces.

In [1]: show threads
<_MainThread(MainThread, started 140574012434176)>
  File "runScrape.py", line 74, in 
go()
  File "runScrape.py", line 57, in go
runner.run()
  File "/media/Storage/Scripts/ReadableWebProxy/WebMirror/Runner.py", line 453, 
in run
living = sum([manager.check_run_jobs() for manager in managers])
  File "/media/Storage/Scripts/ReadableWebProxy/WebMirror/Runner.py", line 453, 
in 
living = sum([manager.check_run_jobs() for manager in managers])
  File "/media/Storage/Scripts/ReadableWebProxy/WebMirror/Runner.py", line 364, 
in check_run_jobs
proc.start()
  File "/usr/lib/python3.5/multiprocessing/process.py", line 105, in start
self._popen = self._Popen(self)
  File "/usr/lib/python3.5/multiprocessing/context.py", line 212, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
  File "/usr/lib/python3.5/multiprocessing/context.py", line 267, in _Popen
return Popen(process_obj)
  File "/usr/lib/python3.5/multiprocessing/popen_fork.py", line 20, in __init__
self._launch(process_obj)
  File "/usr/lib/python3.5/multiprocessing/popen_fork.py", line 74, in _launch
code = process_obj._bootstrap()
  File "/usr/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap
self.run()
  File "/usr/lib/python3.5/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
  File "/media/Storage/Scripts/ReadableWebProxy/WebMirror/Runner.py", line 145, 
in run
run.go()
  File "/media/Storage/Scripts/ReadableWebProxy/WebMirror/Runner.py", line 101, 
in go
self.log.info("RunInstance starting!")
  File "/usr/lib/python3.5/logging/__init__.py", line 1279, in info
self._log(INFO, msg, args, **kwargs)
  File "/usr/lib/python3.5/logging/__init__.py", line 1415, in _log
self.handle(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 1425, in handle
self.callHandlers(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 1487, in callHandlers
hdlr.handle(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 855, in handle
self.emit(record)
  File "/media/Storage/Scripts/ReadableWebProxy/logSetup.py", line 134, in emit
print(outstr)


  File "/usr/lib/python3.5/threading.py", line 882, in _bootstrap
self._bootstrap_inner()
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.5/dist-packages/rpyc/utils/server.py", line 241, 
in start
self.accept()
  File "/usr/local/lib/python3.5/dist-packages/rpyc/utils/server.py", line 128, 
in accept
sock, addrinfo = self.listener.accept()
  File "/usr/lib/python3.5/socket.py", line 195, in accept
fd, addr = self._accept()


  File "/usr/local/lib/python3.5/dist-packages/pystuck/thread_probe.py", line 
15, in thread_frame_generator
yield (thread_, frame)


So, somehow the print() statement is blocking, which I have /no/ idea how to go 
about debugging. I assume there's a lock /in/ the print statement function 
call, and I'm probably going to look into wrapping both the print() call and 
the multiprocessing.Process() call  execution in a single, shared 
multiprocessing lock, but that
seems like a very patchwork solution to something that should just work.

--

___
Python tracker 

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



[issue6721] Locks in the standard library should be sanitized on fork

2016-07-08 Thread Gregory P. Smith

Gregory P. Smith added the comment:

My intent is not to block anything.  I'm Just explaining why I'm not motivated 
to spend much time on this issue myself.  Others are welcome to.

subprocess is not related to this issue, it has been fixed for use with threads 
(in 3.2 and higher) with an extremely widely used drop in replacement back-port 
for 2.7 https://pypi.python.org/pypi/subprocess32.  But even 2.7's poor 
subprocess implementation never triggered this specific issue in the first 
place (unless someone logged from a pre_exec_fn which would be a laughable 
thing to do anyways).

multiprocessing: It has spawn (as of 3.4) and forkserver methods both of which 
can help avoid this issue.  Caveats: spawn understandably has negative 
performance implications and forkserver requires the forkserver to be forked 
before threads potentially holding locks have been started.

As for the gross hacky monkey patching workaround: That was the approach I took 
in 
https://github.com/google/python-atfork/blob/master/atfork/stdlib_fixer.py#L51

Definitely a hack, but one that does work on existing interpreters.

Conner & lesha: Which Python version(s) are you using?

--

___
Python tracker 

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



[issue6721] Locks in the standard library should be sanitized on fork

2016-07-08 Thread lesha

lesha added the comment:

On a moment's reflection, a lot of my prior comment is wrong. Sorry about that. 

- glog does not, that I know of, sanitize locks on fork. You just shouldn't log 
after fork but before exec.

- Using `pthread_atfork` to clean up the `logging` lock might be enough to make 
it safe from the "just forked" context, but without adding fairly exhaustive 
tests around this logic, it would be fragile with respect to further 
improvements to `logging`. So even just making this one library safe is a 
considerable amount of work.

So I retract most of my previous opinion. Sorry.

--

___
Python tracker 

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



[issue6721] Locks in the standard library should be sanitized on fork

2016-07-08 Thread lesha

lesha added the comment:

I work on a multi-million-line C++ codebase that uses fork() from multithreaded 
programs all over the place. We use `glog` ubiquitously.  

This bug here that spans 6 years and has affected dozens of people 
(conservatively) simply does not exist for us. That is because glog takes the 
pragmatic approach of sanitizing its mutex on fork:

https://github.com/google/glog/blob/4d391fe692ae6b9e0105f473945c415a3ce5a401/src/base/mutex.h#L249

In my opinion, "thou shalt never fork() in a threaded program" is impractical 
purism. It is good to be aware of the dangers that lie therein, but it is 
completely possible to safely spawn **subprocesses** from multithreaded 
programs on modern OSes like Linux.

Python's subprocess **ought** to be safe to use in threaded programs. Any 
issues with this (aside from `pre_exec_fn`, obviously) are bugs in 
`subprocess`. 

Here is a C++ implementation of the concept that can be safely used in threaded 
programs:

https://github.com/facebook/folly/blob/master/folly/Subprocess.cpp

Note that unlike Python's subprocess `pre_exec_fn`, the C++ analog is very loud 
in warning you about the scary world in which your closure will execute:

https://github.com/facebook/folly/blob/master/folly/Subprocess.h#L252

The point to my message is simple: there is a pragmatic way to save hundreds of 
debugging hours for users of Python. People are going to find it necessary to 
do such things from time to time, so instead of telling them to redesign their 
programs, it is better to give them a safer tool.

Taking the glog approach in `logging` has no cost to the standard library, but 
it does have real world benefits. 

Please don't block shipping such a fix.

--

___
Python tracker 

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



[issue6721] Locks in the standard library should be sanitized on fork

2016-07-08 Thread Connor Wolf

Connor Wolf added the comment:

Arrrgh, s/threading/multiprocessing/g in my last message.

--

___
Python tracker 

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



[issue6721] Locks in the standard library should be sanitized on fork

2016-07-08 Thread Connor Wolf

Connor Wolf added the comment:

> IMNSHO, working on "fixes" for this issue while ignoring the larger 
> application design flaw elephant in the room doesn't make a lot of sense.

I understand the desire for a canonically "correct" fix, but it seems the issue 
with fixing it "correctly" has lead to the /actual/ implementation being broken 
for at least 6 years now.

As it is, my options are:
A. Rewrite the many, many libraries I use that internally spawn threads.
B. Not use multiprocessing.

(A) is prohibitive from a time perspective (I don't even know how many 
libraries I'd have to rewrite!), and (B) means I'd get 1/24-th of my VMs 
performance, so it's somewhat prohibitive.

At the moment, I've thrown together a horrible, horrible fix where I reach into 
the logging library (which is where I'm seeing deadlocks), and manually iterate 
over all attached log managers, resetting the locks in each immediately when 
each process spawns. 
This is, I think it can be agreed, a horrible, horrible hack, but in my 
particular case it works (the worst case result is garbled console output for a 
line or two). 

---

If a canonical fix is not possible, at least add a facility to the threading 
fork() call that lets the user decide what to do. In my case, my program is 
wedging in the logging system, and I am entirely OK with having transiently 
garbled logs, if it means I don't wind up deadlocking and having to force kill 
the interpreter (which is, I think, far /more/ destructive an action).

If I could basically do `multiprocessing.Process(*args, *kwargs, 
_clear_locks=True)`, that would be entirely sufficient, and not change existing 
behaviour at all.

--

___
Python tracker 

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



[issue6721] Locks in the standard library should be sanitized on fork

2016-07-08 Thread Gregory P. Smith

Gregory P. Smith added the comment:

For me the momentum on fixing these things has stalled because I no longer work 
on any code that runs into this.  There is a fundamental problem: You cannot 
safely use threading and os.fork() in the same application per POSIX rules.  So 
even if the standard library and interpreter to tried to force its locks into 
some sort of consistent state post os.fork(), the much more fundamental POSIX 
problem remains.

IMNSHO, working on "fixes" for this issue while ignoring the larger application 
design flaw elephant in the room doesn't make a lot of sense.

--

___
Python tracker 

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



[issue27469] Unicode filename gets crippled on Windows when drag and drop

2016-07-08 Thread Eryk Sun

Eryk Sun added the comment:

On second thought, it occurred to me that the problem isn't in Explorer or 
shell32, but in the drop handler. It turns out the problem is that the drop 
handler calls the ANSI API DragQueryFileA instead of DragQueryFileW. To see 
this I attached a debugger to Explorer and set a breakpoint on 
shell32!DragQueryFileA:

Breakpoint 0 hit
SHELL32!DragQueryFileA:
7ffd`bed1a5b0 4883ec38sub rsp,38h
0:056> k 3
Child-SP  RetAddr   Call Site
`0ee3e0f8 7ffd`b2c95b7a SHELL32!DragQueryFileA
`0ee3e100 7ffd`bedade2e wshext!CWSHExtension::Drop+0x7a
`0ee3e300 7ffd`bed9d547 
SHELL32!CDVDropTarget::_PerformDrop+0x14a

Note that the shell is deferring to the drop handler for the file type, which 
in our case is implemented by wshext.dll. 

The first DragQueryFileA call is to query the number of files (i.e. iFile == 
0x):

0:056> r rdx
rdx=
0:056> g

The 2nd call gets the ANSI encoded filename:

Breakpoint 0 hit
SHELL32!DragQueryFileA:
7ffd`bed1a5b0 4883ec38sub rsp,38h
0:056> r r8
r8=0ee3e1a0
0:056> pt; da ee3e1a0
`0ee3e1a0  "C:\Temp\A.txt"

The drop handler is set in the Python.File ProgId, which is defined in the 
installer in Tools/msi/launcher/launcher_reg.wxs, which configures the 
following registry entry:

C:\>reg query HKLM\Software\Classes\Python.File\shellex\DropHandler

HKEY_LOCAL_MACHINE\Software\Classes\Python.File\shellex\DropHandler
(Default)REG_SZ{60254CA5-953B-11CF-8C96-00AA00B8708C}

As we previously saw in the stack trace, it's implemented by wshext.dll:

C:\>reg query 
HKLM\Software\Classes\CLSID\{60254CA5-953B-11CF-8C96-00AA00B8708C} /s


HKEY_LOCAL_MACHINE\Software\Classes\CLSID\{60254CA5-953B-11CF-8C96-00AA00B8708C}
(Default)REG_SZShell Extension For Windows Script Host


HKEY_LOCAL_MACHINE\Software\Classes\CLSID\{60254CA5-953B-11CF-8C96-00AA00B8708C}\InProcServer32
(Default)REG_SZC:\Windows\System32\wshext.dll
ThreadingModelREG_SZApartment


I thought I could fix this easily by switching to the drop handler that batfile 
and exefile use:

C:\>reg add HKLM\Software\Classes\Python.File\shellex\DropHandler /ve /d ^
More? {86C86720-42A0-1069-A2E8-08002B30309D}
Value  exists, overwrite(Yes/No)? y
The operation completed successfully.

This gets the Unicode filename right, but when I move "Ā.txt" to a directory 
under "Program Files", I see that it uses short filenames in the path. 

['C:\\PROGRA~1\\Python35\\Ā.txt']

Is that acceptable?

--
resolution: third party -> 
stage: resolved -> 
status: closed -> open

___
Python tracker 

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



[issue6721] Locks in the standard library should be sanitized on fork

2016-07-08 Thread Connor Wolf

Connor Wolf added the comment:

Is anything happening with these fixes? This is still an issue (I'm running 
into it now)?

--
nosy: +Connor.Wolf

___
Python tracker 

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



[issue25435] Wrong function calls and referring to not removed concepts in descriptor HowTo (documentation)

2016-07-08 Thread Eryk Sun

Eryk Sun added the comment:

I'm surprised it's not documented for the types module:

https://docs.python.org/3.5/library/types.html#types.MethodType

At least the docstring has the parameters:

>>> print(types.MethodType.__doc__)
method(function, instance)

Create a bound instance method object.

--
nosy: +eryksun

___
Python tracker 

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



[issue27442] expose the Android API level in sysconfig.get_config_vars()

2016-07-08 Thread Stefan Krah

Stefan Krah added the comment:

I guess so. Our Rietveld setup apparently has some heuristics that work best 
when you're on the default branch and completely synced with the main repo.

--

___
Python tracker 

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



[issue27471] sre_constants.error: bad escape \d

2016-07-08 Thread R. David Murray

R. David Murray added the comment:

It's just supposed to be a warning at this point, though, so this looks like a 
bug.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue27471] sre_constants.error: bad escape \d

2016-07-08 Thread Matthew Barnett

Matthew Barnett added the comment:

There's a move to treat invalid escape sequences as an error (see issue 27364). 
The previous behaviour was to treat them as literals.

The replacement template string contains \d, which is not a valid escape 
sequence (it's valid for the pattern, but not the template).

--
type: crash -> behavior

___
Python tracker 

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



[issue27471] sre_constants.error: bad escape \d

2016-07-08 Thread Noah Petherbridge

New submission from Noah Petherbridge:

I found a bug in Python 3.6.0a2 that wasn't present on previous versions of 
Python concerning the "\d" escape sequence as used in the following regular 
expression:

import re
s = "hello"
s = re.sub(re.escape(r'(\d+?)'), '(?:\d+?)', s)

(The purpose of this regular expression was to translate the literal regexp 
string "(\d+?)" to be a non-capturing literal regexp string, to eventually be 
used as a re pattern).

When running this code in 3.6.0a2 I receive the following stack traces:

- - - - - - - - - -

Traceback (most recent call last):
  File "/home/kirsle/.pyenv/versions/3.6.0a2/lib/python3.6/sre_parse.py", line 
877, in parse_template
this = chr(ESCAPES[this][1])
KeyError: '\\d'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 4, in 
s = re.sub(re.escape(r'(\d+?)'), '(?:\d+?)', s)
  File "/home/kirsle/.pyenv/versions/3.6.0a2/lib/python3.6/re.py", line 181, in 
sub
return _compile(pattern, flags).sub(repl, string, count)
  File "/home/kirsle/.pyenv/versions/3.6.0a2/lib/python3.6/re.py", line 324, in 
_subx
template = _compile_repl(template, pattern)
  File "/home/kirsle/.pyenv/versions/3.6.0a2/lib/python3.6/re.py", line 311, in 
_compile_repl
p = sre_parse.parse_template(repl, pattern)
  File "/home/kirsle/.pyenv/versions/3.6.0a2/lib/python3.6/sre_parse.py", line 
880, in parse_template
raise s.error('bad escape %s' % this, len(this))
sre_constants.error: bad escape \d at position 3

- - - - - - - - - -

However, the script runs without crashing on Python 3.5.1 and 2.7.11

% python --version
Python 3.6.0a2

--
components: Regular Expressions
messages: 270010
nosy: Noah Petherbridge, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: sre_constants.error: bad escape \d
type: crash
versions: Python 3.6

___
Python tracker 

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



[issue27469] Unicode filename gets crippled on Windows when drag and drop

2016-07-08 Thread Eryk Sun

Eryk Sun added the comment:

Nothing can be done about this from Python. It's a bug in how Explorer handles 
the dropped filename. 

Note that it's not simply replacing Unicode characters with question marks. 
It's using a best-fit ANSI encoding. For example, codepage 1252 maps "Ā" to 
"A". If there's no defined best-fit mapping, most codepages default to using 
"?" as the replacement character when encoding via WideCharToMultiByte. When 
decoding via MultiByteToWideChar, some codepages (e.g. 932), use katakana 
middle dot (U+30FB) as the default instead of a question mark.

For example, here's the commandline of py.exe when I drop a file named "Ā.txt" 
on a script. Note that "Ā" becomes "A":

0:000> ?? @$peb->ProcessParameters->CommandLine
struct _UNICODE_STRING
 ""C:\Windows\py.exe" "C:\Temp\test.py" C:\Temp\A.txt "
   +0x000 Length   : 0x68
   +0x002 MaximumLength: 0x6a
   +0x004 Buffer   : 0x00771d50  ""C:\Windows\py.exe" 
"C:\Temp\test.py" C:\Temp\A.txt "

It's bizarre that it encodes the filename as ANSI just to decode it later when 
it calls CreateProcess. But Explorer probably still has a lot old code from 
back when it had to run on both Windows NT and DOS-based Windows 9x. This is 
probably a vestige of some workaround.

It isn't a problem if you ShellExecuteEx the Python script. For example, I ran 
"C:\Temp\test.py C:\Temp\Ā.txt" in the command prompt, and here's the resulting 
command line:

0:000> ?? @$peb->ProcessParameters->CommandLine
struct _UNICODE_STRING
 ""C:\Windows\py.exe" "C:\Temp\test.py"  C:\Temp\Ā.txt"
   +0x000 Length   : 0x68
   +0x002 MaximumLength: 0x6a
   +0x004 Buffer   : 0x00981cf8  ""C:\Windows\py.exe" 
"C:\Temp\test.py"  C:\Temp\Ā.txt"

Explorer actually handles drag and drop correctly when dropping the file on 
another window. So as a (clunky) workaround, you can drag the script icon into 
a command prompt or Win+R run dialog, and then drag the target file. The shell 
should add quotes where required.

--
nosy: +eryksun
resolution:  -> third party
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue27442] expose the Android API level in sysconfig.get_config_vars()

2016-07-08 Thread Xavier de Gaye

Xavier de Gaye added the comment:

Thanks Berker and Stefan for your help on 'hg diff --git'. Yes Stefan, maybe 
your patch has a [review] button because Rietveld found that your patch applied 
cleanly against the head of the default branch at the time you have submitted 
it, so it could guess the base revision while mines were submitted late, or 
rather without a 'hg pull -u' right before the submission ?

--

___
Python tracker 

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



[issue25435] Wrong function calls and referring to not removed concepts in descriptor HowTo (documentation)

2016-07-08 Thread Daniel Holth

Daniel Holth added the comment:

This bit me also. Is there other documentation for how many arguments 
MethodType() should take?

--
nosy: +dholth

___
Python tracker 

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



[issue26896] mix-up with the terms 'importer', 'finder', 'loader' in the import system and related code

2016-07-08 Thread Oren Milman

Oren Milman added the comment:

That's awesome! Thanks :)

--

___
Python tracker 

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



[issue20842] pkgutil docs should reference glossary terms not PEP 302

2016-07-08 Thread Oren Milman

Oren Milman added the comment:

Note that http://bugs.python.org/issue26896 is now closed (the patches proposed 
in it (with some minor changes) were committed).

--
nosy: +Oren Milman

___
Python tracker 

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



[issue27285] Document the deprecation of pyvenv in favor of `python3 -m venv`

2016-07-08 Thread Steve Piercy

Steve Piercy added the comment:

Thank you!

--

___
Python tracker 

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



[issue26415] Excessive peak memory consumption by the Python parser

2016-07-08 Thread A. Skrobov

A. Skrobov added the comment:

Fixing whitespace in the patch, and including an update for the docs

--
Added file: http://bugs.python.org/file43664/patch

___
Python tracker 

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



[issue26972] mistakes in docstrings in the import machinery

2016-07-08 Thread Brett Cannon

Brett Cannon added the comment:

Thanks for the patch, Oren! The only real change I made was to make sure the 
the one-sentence summary at the start of the docstring fit on a single line 
(when it spans line it can muck up editors and tools).

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue26415] Excessive peak memory consumption by the Python parser

2016-07-08 Thread A. Skrobov

Changes by A. Skrobov :


Added file: http://bugs.python.org/file43665/devguide_patch

___
Python tracker 

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



[issue26972] mistakes in docstrings in the import machinery

2016-07-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d32517de5d8c by Brett Cannon in branch 'default':
Issue #26972: Fix some mistakes in importlib-related docstrings.
https://hg.python.org/cpython/rev/d32517de5d8c

--
nosy: +python-dev

___
Python tracker 

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



[issue26896] mix-up with the terms 'importer', 'finder', 'loader' in the import system and related code

2016-07-08 Thread Brett Cannon

Brett Cannon added the comment:

Thanks for the patch, Oren! Only change I made was deleting the lines you 
commented out in the tests.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue26896] mix-up with the terms 'importer', 'finder', 'loader' in the import system and related code

2016-07-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c65f34dafcc1 by Brett Cannon in branch 'default':
Issue #26896: Disambiguate uses of "importer" with "finder".
https://hg.python.org/cpython/rev/c65f34dafcc1

--
nosy: +python-dev

___
Python tracker 

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



[issue27285] Document the deprecation of pyvenv in favor of `python3 -m venv`

2016-07-08 Thread Brett Cannon

Brett Cannon added the comment:

Thanks for the patch, Steve! I went ahead and got this done now when I realized 
your patch touched so many files, thus waiting could lead to skew and the need 
to update the patch needlessly.

--
resolution:  -> fixed
stage: needs patch -> resolved
status: open -> closed

___
Python tracker 

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



[issue27285] Document the deprecation of pyvenv in favor of `python3 -m venv`

2016-07-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 414f67e000a7 by Brett Cannon in branch 'default':
Issue #27285: Document the deprecation of the pyvenv script.
https://hg.python.org/cpython/rev/414f67e000a7

--
nosy: +python-dev

___
Python tracker 

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



[issue27468] Erroneous memory behaviour for objects created in another thread

2016-07-08 Thread Emanuel Barry

Changes by Emanuel Barry :


--
resolution:  -> not a bug
stage:  -> resolved

___
Python tracker 

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



[issue27468] Erroneous memory behaviour for objects created in another thread

2016-07-08 Thread Adria Garriga

Adria Garriga added the comment:

Yes, that seems to be it. Storing info in the Thread object is just for the 
sake of keeping the example short, but the error is the same you pointed out.

Thank you very much and I hope I didn't waste too much of your time!

--
status: open -> closed

___
Python tracker 

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



[issue27468] Erroneous memory behaviour for objects created in another thread

2016-07-08 Thread Peter Otten

Peter Otten added the comment:

Your code relies on the assumption that when the lambda is invoked the global t 
is still bound to the Thread instance you are starting. It seems that this is 
not always the case, and I don't see why it should be guaranteed either.
I don't know whether it's a good idea to store per-thread data in the Thread 
instance (have a look at threading.local()), but

def start_thread():
t = Thread(target=lambda: f(t))
t.obj = [0]
t.start()

for _ in range(n_threads):
start_thread()

will at least avoid the global.

--
nosy: +peter.otten

___
Python tracker 

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



[issue27470] -3 commandline option documented differently via man

2016-07-08 Thread Matthew Gilson

New submission from Matthew Gilson:

The man page for python says:

> Warn about Python 3.x incompatibilities that 2to3 cannot trivially fix.

The official documentation 
(https://docs.python.org/2/using/cmdline.html#cmdoption-3) does not mention 
2to3 at all:

> Warn about Python 3.x possible incompatibilities by emitting a 
> DeprecationWarning for features that are removed or significantly changed in 
> Python 3.

This seems like a pretty big oversight when the following code issues no 
warnings (presumably because 2to3 can trivially handle this change):

```
from __future__ import print_function

class test(object):
def __nonzero__(self):
return False

t = test()
if t:
print('Hello')
```

--
assignee: docs@python
components: Documentation
messages: 269994
nosy: docs@python, mgilson
priority: normal
severity: normal
status: open
title: -3 commandline option documented differently via man
versions: Python 2.7

___
Python tracker 

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



[issue22624] Bogus usage of floatclock in timemodule

2016-07-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 1452520dfe7b by Victor Stinner in branch 'default':
Issue #22624: Python 3 requires clock() to build
https://hg.python.org/cpython/rev/1452520dfe7b

--
nosy: +python-dev

___
Python tracker 

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



[issue17213] ctypes loads wrong version of C runtime, leading to error message box from system

2016-07-08 Thread Keno Fischer

Keno Fischer added the comment:

pyzmq has a similar issue. I believe one solution would be to call
`_Py_ActivateActCtx` in ctypes' load_library, i.e. do
```
#if HAVE_SXS
ULONG_PTR cookie = _Py_ActivateActCtx();
#endif
hMod = LoadLibraryW(name);
#if HAVE_SXS
_Py_DeactivateActCtx(cookie);
#endif
```
in that function. I don't know enough about python or ctypes to say whether 
this patch works as is (_Py_ActivateActCtx seems to be an internal function, 
not sure if ctypes has access to that).

--
nosy: +Keno Fischer

___
Python tracker 

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



[issue27469] Unicode filename gets crippled on Windows when drag and drop

2016-07-08 Thread Emanuel Barry

Changes by Emanuel Barry :


--
nosy: +ebarry

___
Python tracker 

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



[issue27469] Unicode filename gets crippled on Windows when drag and drop

2016-07-08 Thread Adam Bartoš

New submission from Adam Bartoš:

When a Python script is run by drag-and-dropping another file on it in Windows 
explorer, the other file's path becomes sys.argv[1]. However, when the path 
contains a Unicode characters (e.g. α), it gets crippled – it is replaced by 
ordinary question mark.

Maybe this is not Python's fault. Calling directly GetCommandLineW already 
contains that question mark. I'm just curious whether the original path even 
can be reconstructed.

--
components: Unicode, Windows
messages: 269991
nosy: Drekin, ezio.melotti, haypo, paul.moore, steve.dower, tim.golden, 
zach.ware
priority: normal
severity: normal
status: open
title: Unicode filename gets crippled on Windows when drag and drop
type: behavior
versions: Python 3.5, Python 3.6

___
Python tracker 

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



[issue22624] Bogus usage of floatclock in timemodule

2016-07-08 Thread STINNER Victor

STINNER Victor added the comment:

Sorry but the Wii console is not supported. You have to maintain your 
fork/patch.

Python 3 don't support platforms without clock().

--
resolution:  -> wont fix
status: open -> closed

___
Python tracker 

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



[issue27468] Erroneous memory behaviour for objects created in another thread

2016-07-08 Thread Adria Garriga

New submission from Adria Garriga:

I create several objects in the main thread, and then spawn several threads 
that "take ownership" of one object each. Within that thread, the objects' 
attributes' values are not consistent. The bug only happens sometimes.

from threading import Thread
import pdb
n_threads = 8

def f(self):
self.obj[0] = 0
t = 0
while True:
if t != self.obj[0]:
pdb.set_trace() # should not happen
t += 1
self.obj[0] += 1

for _ in range(n_threads):
t = Thread(target=lambda: f(t))
t.obj = [0]
t.start()


Tested in Python 2.7.11 under Ubuntu 16.04 LTS and OS X. The bug does not 
happen in Python 3.5 or Python 3.6 .

Attached is a very similar program that exhibits the same issue, but which may 
be clearer and can sometimes be killed with Ctrl-C.

--
components: Library (Lib)
files: test.py
messages: 269988
nosy: Adria Garriga
priority: normal
severity: normal
status: open
title: Erroneous memory behaviour for objects created in another thread
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file43663/test.py

___
Python tracker 

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



[issue27466] [Copy from github user macartur] time2netscape missing comma

2016-07-08 Thread Robby Daigle

Robby Daigle added the comment:

Thanks!

--

___
Python tracker 

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



[issue27468] Erroneous memory behaviour for objects created in another thread

2016-07-08 Thread Adria Garriga

Changes by Adria Garriga :


Removed file: http://bugs.python.org/file43663/test.py

___
Python tracker 

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



[issue27441] redundant assignments to ob_size of new ints that _PyLong_New returned

2016-07-08 Thread Oren Milman

Oren Milman added the comment:

I am sorry, but I can't see why micro-benchmarking is needed here, as my 
patches only remove code that does nothing, while they don't add any new code.

The assembly the compiler generates (on my PC) for 'Py_SIZE(v) = negative ? 
-ndigits : ndigits;' in PyLong_FromLongLong is: 
('[edx+8]' is 'Py_SIZE(v)',
 '[esp+10h+var_4]' is 'negative',
  The 'lea ecx, [edx+0Ch]' and 'mov eax, edi' instructions set ecx and eax for 
later (I haven't removed them in order to be as precise as possible.))
...
cmp [esp+10h+var_4], 0
lea ecx, [edx+0Ch]
jz  short loc_1E0D48EC
neg ebx
loc_1E0D48EC:
mov eax, edi
mov [edx+8], ebx
...
In contrast, the assembly the compiler generates for 'if (negative) Py_SIZE(v) 
= -ndigits;' is:
...
cmp [esp+10h+var_4], 0
lea ecx, [edx+0Ch]
jz  short loc_1E0D482F
neg ebx
mov [edx+8], ebx
loc_1E0D482F:
mov eax, edi
...
Comparing the assembly generated for the other original '?:' expressions with 
my corresponding patches looks quite the same. Each patch moves the assignment 
from code which is executed in both of the flows, to code which is executed in 
only one of the flows.

Am I missing anything that might cause my patches to introduce a performance 
penalty?


I searched (all of the cpython repo) for other places in which Py_SIZE() is set 
to the same value, and indeed found one in Objects/longobject.c in _PyLong_Init:
The loop that initializes the small_ints array goes over every element in the 
array, and checks whether it was already initialized. For some reason, even 
when it realizes the current element was already initialized, it still sets 
'Py_SIZE(v)' and 'v->ob_digit[0]' (to the values they are already set to).
These redundant assignments were first added in changeset 45072 
(https://hg.python.org/cpython/rev/f183f1189824), and remained there to this 
day.

So I added a patch to move these assignments so they would be executed only in 
case the current element of small_ints wasn't already initialized.
The updated patches diff file is attached. I also ran the tests again, and got 
quite the same output (the output is attached).

Have you spotted any other places in which Py_SIZE() is set to the same value?

--
Added file: http://bugs.python.org/file43661/issue27441_ver2.diff

___
Python tracker 

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



[issue27441] redundant assignments to ob_size of new ints that _PyLong_New returned

2016-07-08 Thread Oren Milman

Changes by Oren Milman :


Added file: http://bugs.python.org/file43662/patchedCPythonTestOutput_ver2.txt

___
Python tracker 

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



[issue27269] ipaddress: Wrong behavior with ::ffff:1.2.3.4 style IPs

2016-07-08 Thread Марк Коренберг

Марк Коренберг added the comment:

Also, it should be marked explicitly, if cross-type lookup is safe. I mean code 
like that:

some_net = ipaddress.ip_network(some_input1)
some_addr = ipaddress.ip_address(some_input2)
return some_addr in some_net

Is it safe to write such code? Docs say:

21.28.2.3. Operators
Address objects support some operators. Unless stated otherwise,
operators can only be applied between compatible objects
(i.e. IPv4 with IPv4, IPv6 with IPv6).

1. It is not said if exception will be raised if incompatible objects are used, 
and not said if result is defined.
2. "Unless stated otherwise" - Seem it is stated nowhere.

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python

___
Python tracker 

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



[issue27269] ipaddress: Wrong behavior with ::ffff:1.2.3.4 style IPs

2016-07-08 Thread Марк Коренберг

Марк Коренберг added the comment:

see also issue20446

--
nosy: +mmarkk

___
Python tracker 

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



[issue20446] ipaddress: hash similarities for ipv4 and ipv6

2016-07-08 Thread Марк Коренберг

Марк Коренберг added the comment:

See also issue20446

--
nosy: +mmarkk

___
Python tracker 

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



[issue20446] ipaddress: hash similarities for ipv4 and ipv6

2016-07-08 Thread Марк Коренберг

Марк Коренберг added the comment:

Sorry. See also issue27269

--

___
Python tracker 

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



[issue27442] expose the Android API level in sysconfig.get_config_vars()

2016-07-08 Thread Stefan Krah

Stefan Krah added the comment:

Good point about Misc/NEWS: I just regenerated the patch mindlessly to check 
the "diff --git" situation :)

Actually, Xavier, it's often better to leave out the NEWS section in the bug 
tracker patches and just add it before pushing. Perhaps Rietveld choked on the 
NEWS file before because it's constantly changing?

--

___
Python tracker 

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



[issue27442] expose the Android API level in sysconfig.get_config_vars()

2016-07-08 Thread STINNER Victor

STINNER Victor added the comment:

issue27442-3.patch: be careful, the new item in Misc/NEWS is not at the top of 
its section. Moreover, I still consider that the unit test is risky and not 
really needed (just remove it).

Good job, there is now a [review] button :-)

--

___
Python tracker 

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



[issue27464] Document that SplitResult & friends are namedtuples

2016-07-08 Thread SilentGhost

Changes by SilentGhost :


--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python
stage:  -> needs patch
versions: +Python 3.5, Python 3.6

___
Python tracker 

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



[issue27442] expose the Android API level in sysconfig.get_config_vars()

2016-07-08 Thread Stefan Krah

Stefan Krah added the comment:

I did "hg pull -u" before re-generating the diff.  Other than that, sometimes 
newer mercurial versions behave better (I have 2.8.2).

--

___
Python tracker 

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



[issue27442] expose the Android API level in sysconfig.get_config_vars()

2016-07-08 Thread Stefan Krah

Changes by Stefan Krah :


Added file: http://bugs.python.org/file43660/issue27442-3.patch

___
Python tracker 

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



[issue27467] distutils.config API different between <=3.5.1 and 3.5.2

2016-07-08 Thread Berker Peksag

Berker Peksag added the comment:

I was thinking to document issue 20120 in Misc/NEWS. It turns out I was looking 
at the wrong commit and it was already documented in eae59b6bf133.

--
resolution:  -> not a bug
stage: needs patch -> resolved
status: open -> closed

___
Python tracker 

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



[issue27467] distutils.config API different between <=3.5.1 and 3.5.2

2016-07-08 Thread Xiang Zhang

Xiang Zhang added the comment:

Berker, what doc needs to be changed? Although RawConfigParser is legacy but 
that does not mean it's deprecated, right? We can still use it although the doc 
suggests us use ConfigParser.

--

___
Python tracker 

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



[issue11027] Implement sectionxform in configparser

2016-07-08 Thread Berker Peksag

Berker Peksag added the comment:

Issue 26537 is a duplicate of this one but it has an up-to-date and more 
complete patch so I'm going to close this one.

--
nosy: +berker.peksag
resolution:  -> duplicate
stage: needs patch -> resolved
status: open -> closed
superseder:  -> ConfigParser has optionxform, but not sectionxform

___
Python tracker 

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



[issue27467] distutils.config API different between <=3.5.1 and 3.5.2

2016-07-08 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the report. Yes, the RawConfigParser change was intentional and it 
was discussed in issue 20120. I'm marking this as a documentation issue.

--
assignee:  -> docs@python
components: +Documentation
nosy: +berker.peksag, docs@python
stage:  -> needs patch
versions: +Python 3.6

___
Python tracker 

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



[issue27467] distutils.config API different between <=3.5.1 and 3.5.2

2016-07-08 Thread Xiang Zhang

Xiang Zhang added the comment:

I think it's intentional. You can see issue20120.

--
nosy: +xiang.zhang

___
Python tracker 

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