Re: Alternatives to XML?

2016-08-25 Thread Frank Millman

"Peter Otten"  wrote in message news:npn25e$s5n$1...@blaine.gmane.org...

Frank Millman wrote:


As you have to keep the "<", why bother?


If you mean why don't I convert the '<' to '', the answer is that I do
- I just omitted to say so. However, explicit is better than implicit :-)


Doesn't that make the XML document invalid or changes it in an 
irreversible way? How would you know whether


""

started out as

""

or

"bar/>"

?

I cheat ;-)

It is *my* XML, and I know that I only use the offending characters inside 
attributes, and attributes are the only place where double-quote marks are 
allowed.


So this is my conversion routine -

lines = string.split('"')  # split on attributes
for pos, line in enumerate(lines):
   if pos%2:  # every 2nd line is an attribute
   lines[pos] = line.replace('', '<').replace('', '>')
return '"'.join(lines)

Frank


--
https://mail.python.org/mailman/listinfo/python-list


[issue27842] Order CSV header fields

2016-08-25 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Consider using itertools.permutations() to generate the 120 cases cases.

The news entry goes into Misc/NEWS (there is not .txt extension).

--

___
Python tracker 

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



[issue19504] Change "customise" to "customize".

2016-08-25 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Thanks for the patch.

--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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



[issue19504] Change "customise" to "customize".

2016-08-25 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 579360b1c8fe by Raymond Hettinger in branch '3.5':
Issue 19504:  Change "customise" to "customize" American spelling.
https://hg.python.org/cpython/rev/579360b1c8fe

--

___
Python tracker 

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



[issue19504] Change "customise" to "customize".

2016-08-25 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: docs@python -> rhettinger
nosy: +rhettinger

___
Python tracker 

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



[issue27840] functools.partial: don't copy keywoard arguments in partial_call()?

2016-08-25 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I concur with Antoine.

--

___
Python tracker 

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



[issue27833] Process is locked when try to execute Queue.put() inside

2016-08-25 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Davin, what are your thoughts?

--
assignee:  -> davin
nosy: +rhettinger

___
Python tracker 

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



[issue27858] Add identity function to functools

2016-08-25 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
resolution:  -> rejected
status: open -> closed

___
Python tracker 

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



[issue27852] itertools -> flatten_all()

2016-08-25 Thread Raymond Hettinger

Raymond Hettinger added the comment:

> I think there is no need add this function in itertools. 
> And due to this details it may be not worth to add it as a recipe.

Sorry YoSTEALTH, I concur with Serhiy on both points and am going to pass on 
this proposal. 

That said, I encourage you to post elsewhere.  When my own ideas don't make it 
to the docs or standard library, I usually post a recipe in the ASPN Python 
Cookbook (for example, see https://code.activestate.com/recipes/users/178123/ ).

--
resolution:  -> rejected
status: open -> closed

___
Python tracker 

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



[issue27860] Improvements to ipaddress module

2016-08-25 Thread Xiang Zhang

Changes by Xiang Zhang :


--
nosy: +xiang.zhang

___
Python tracker 

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



[issue27865] WeakMethod does not support builtin methods

2016-08-25 Thread Antony Lee

New submission from Antony Lee:

List subclasses can be weakref'd (as mentioned by the docs), but their methods 
cannot be wrapped by WeakMethod, even though this makes sense semantically:
```
In [25]: class L(list): pass

In [26]: weakref.WeakMethod(L().append)
---
TypeError Traceback (most recent call last)
 in ()
> 1 weakref.WeakMethod(L().append)

/usr/lib/python3.5/weakref.py in __new__(cls, meth, callback)
 47 except AttributeError:
 48 raise TypeError("argument should be a bound method, not {}"
---> 49 .format(type(meth))) from None
 50 def _cb(arg):
 51 # The self-weakref trick is needed to avoid creating a 
reference

TypeError: argument should be a bound method, not 
```

--
components: Library (Lib)
messages: 273688
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: WeakMethod does not support builtin methods
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



[issue17642] IDLE add font resizing hot keys and wheel

2016-08-25 Thread Terry J. Reedy

Terry J. Reedy added the comment:

https://stackoverflow.com/questions/39155656/i-need-bigger-font-in-python-idle/39156068#39156068
 is about getting a larger font size than 22 for classroom projection.  I think 
configdialog.py should be extended something as follows (about line 1000).

self.optMenuFontSize.SetMenu(('7', '8', '9', '10', '11', '12', '13',
  '14', '16', '18', '20', '22',
  '25', '30', '35', '40'), fontSize )
 
I think any new key or wheel should change by 1 over a large range rather than 
being constrained to the values on the list.  I will try to look at the patches 
before 3.6.  Tests should also be added.

--
assignee: roger.serwy -> terry.reedy
stage: needs patch -> patch review
title: IDLE add font resizing hot keys -> IDLE add font resizing hot keys and 
wheel
versions: +Python 3.6 -Python 3.4

___
Python tracker 

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



[issue19884] Importing readline produces erroneous output

2016-08-25 Thread Martin Panter

Martin Panter added the comment:

Thanks, I can try to commit the version fix part of the patch when I get a 
chance. What is EL6.8, is that a Red Hat (Enterprise Linux) thing?

--
versions: +Python 3.6 -Python 3.4

___
Python tracker 

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



[issue27213] Rework CALL_FUNCTION* opcodes

2016-08-25 Thread STINNER Victor

STINNER Victor added the comment:

I'm working on a new calling convention: "fast call".

I already pushed changes implementing first functions:

_PyObject_FastCallDict(PyObject *func, PyObject **stack, Py_ssize_t nargs, 
PyObject *kwargs)

kwargs is a Python dict, but it can be NULL.

_PyObject_FastCallDict() avoids the creation a temporary tuple when you don't 
have to pass keyword arguments.

But I'm interested by an evolution to avoid also the creation of a temporary 
dictionary: issue #27830, "Add _PyObject_FastCallKeywords(): avoid the creation 
of a temporary dictionary for keyword arguments". This function would be the 
fundation for a new calling convention for C functions: #27810, "Add 
METH_FASTCALL: new calling convention for C functions".

I didn't read your patch carefully, but I would like to make sure that your 
patch would benefit of these APIs to avoid the creation of temporary tuple 
and/or dict.

"func(*args, key=value)" uses CALL_FUNCTION_EX and so requires to create a 
temporary dictionary. Maybe it's ok, I don't think that this syntax is commonly 
used.

"func(*args)" uses CALL_FUNCTION_EX: if args is a tuple, can you confirm that 
it would be possible to use _PyObject_FastCallDict() and/or 
_PyObject_FastCallKeywords() to avoid the creation a new temporary tuple?

Hum, I don't think that "func(*args)" can be optimized if args is a list 
because a list is mutable, we cannot use a direct access to the internal C 
array of a list.

--

___
Python tracker 

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



Re: Python non blocking multi-client service

2016-08-25 Thread sohcahtoa82
On Tue, Aug 23, 2016 at 11:39 PM,   wrote:
> On Tuesday, August 23, 2016 at 6:42:53 AM UTC-7, Chris Angelico wrote:
> > On Tuesday, August 23, 2016 at 4:09:07 PM UTC+3, dimao wrote:
> > >   except:
> > >print ('Error')
> >
> >
> > Don't do this.
> >
> > ChrisA
> 
> I did that only for the debug reasons :-)

That makes it even worse.  If you're trying to debug something, you want as 
much information as you can get, and you're throwing it all away.

If you want your program to keep going no matter what happened, at *least* 
print the stack trace, and not just "Error".
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Asynchronous programming

2016-08-25 Thread Terry Reedy

On 8/11/2016 11:55 PM, Lawrence D’Oliveiro wrote:

On Friday, August 12, 2016 at 2:25:05 AM UTC+12, Terry Reedy wrote:


When I read something like "Python finally acquired an event loop in
3.4" I wonder where people have been.  The tk event loop has been in
Python perhaps for 2 decades...


As was pointed out to me just a few days ago, that’s Tcl, not Python.


Tk is part of Tcl/Tk.  Tk's mainloop() calls level tcl loop functions.

The tkinter and _tkinter modules are Python stdlib modules.  For 
timer-based callbacks, there is little difference between using tkinter 
and async modules.  The fact that async uses a Python-coded event loop 
while tkinter uses a Tcl-coded loop is nearly invisible.  Several other 
stdlib modules wrap 'foreign' code too.


--
Terry Jan Reedy


--
https://mail.python.org/mailman/listinfo/python-list


[issue27213] Rework CALL_FUNCTION* opcodes

2016-08-25 Thread STINNER Victor

STINNER Victor added the comment:

> Pybench is now only ~200ms slower instead of 1200ms slower. But the whole 
> point of this patch is that CALL_FUNCTION_EX shouldn't be optimized for, so 
> I'd much prefer real benchmarking results

FYI I released a first version of the "new" Python benchmark suite: performance 
0.1 (quickly fixed with performance 0.1.1):

* https://pypi.python.org/pypi/performance
* https://github.com/python/benchmarks

The README file contains a few information how to run a stable benchmark. 
Please help me to complete this documentation :-)

I may help you to run these benchmarks.

--

___
Python tracker 

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



[issue27852] itertools -> flatten_all()

2016-08-25 Thread YoSTEALTH

YoSTEALTH added the comment:

Currently there is flatten() function in itertools Recipes section. This is 
what it does:
-> a = ['one', 'plus', [b'two', b'three'], ['four', ('five', (1, {'e', 'ee'}, 
(2, (3, ))), ['six'])], generator()]
<- ['o', 'n', 'e', 'p', 'l', 'u', 's', b'two', b'three', 'four', ('five', (1, 
{'ee', 'e'}, (2, (3,))), ['six']), 0, 1, 2]

As you can see it only flattens 1 nested level and for some reason it explodes 
the 'one' and 'plus' str items (maybe intentionally designed or lazily ignored, 
i don't know).

This is useful maybe in special circumstances where you have:
-> a = [[1, 2, 3], ['one', 'two', 'three']]
<- [1, 2, 3, 'one', 'two', 'three']

Also it doesn't work with bytearray, memoryview ...


In real worldly use something like flatten_all() is more useful!

--

___
Python tracker 

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



[issue27864] test_socket: unknown thread blocks forever on "AMD64 FreeBSD 9.x 3.x"

2016-08-25 Thread STINNER Victor

New submission from STINNER Victor:

http://buildbot.python.org/all/builders/AMD64%20FreeBSD%209.x%203.x/builds/4736/steps/test/logs/stdio

...
running: test_socket (778 sec)
running: test_socket (808 sec)
running: test_socket (838 sec)
running: test_socket (868 sec)
running: test_socket (898 sec)
0:17:29 [402/402/1] test_socket crashed
Timeout (0:15:00)!
Thread 0x000801807400 (most recent call first):
  File "/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/threading.py", 
line 295 in wait
  File "/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/threading.py", 
line 551 in wait
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/test_socket.py", 
line 261 in _tearDown
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/unittest/case.py", line 
603 in run
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/unittest/case.py", line 
648 in __call__
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/unittest/suite.py", 
line 122 in run
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/unittest/suite.py", 
line 84 in __call__
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/unittest/suite.py", 
line 122 in run
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/unittest/suite.py", 
line 84 in __call__
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/unittest/runner.py", 
line 176 in run
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/support/__init__.py",
 line 1810 in _run_suite
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/support/__init__.py",
 line 1844 in run_unittest
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/test_socket.py", 
line 5385 in test_main
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/libregrtest/runtest.py",
 line 164 in runtest_inner
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/libregrtest/runtest.py",
 line 119 in runtest
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/libregrtest/runtest_mp.py",
 line 71 in run_tests_slave
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/libregrtest/main.py",
 line 471 in _main
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/libregrtest/main.py",
 line 464 in main
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/libregrtest/main.py",
 line 526 in main
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/regrtest.py", line 
46 in _main
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/regrtest.py", line 
50 in 
  File "/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/runpy.py", line 
85 in _run_code
  File "/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/runpy.py", line 
193 in _run_module_as_main


Traceback (most recent call last):
  File "/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/runpy.py", line 
193, in _run_module_as_main
"__main__", mod_spec)
  File "/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/runpy.py", line 
85, in _run_code
exec(code, run_globals)
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/__main__.py", line 
2, in 
main()
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/libregrtest/main.py",
 line 526, in main
Regrtest().main(tests=tests, **kwargs)
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/libregrtest/main.py",
 line 464, in main
self._main(tests, kwargs)
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/libregrtest/main.py",
 line 484, in _main
self.run_tests()
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/libregrtest/main.py",
 line 412, in run_tests
run_tests_multiprocess(self)
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd9/build/Lib/test/libregrtest/runtest_mp.py",
 line 221, in run_tests_multiprocess
raise Exception(msg)
Exception: Child error on test_socket: Exit code 1

--
components: Tests
keywords: buildbot
messages: 273682
nosy: haypo, koobs
priority: normal
severity: normal
status: open
title: test_socket: unknown thread blocks forever on "AMD64 FreeBSD 9.x 3.x"
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



[issue27845] Optimize update_keyword_args() function

2016-08-25 Thread STINNER Victor

STINNER Victor added the comment:

See also the issue #27358: "BUILD_MAP_UNPACK_WITH_CALL is slow.

--

___
Python tracker 

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



[issue27358] BUILD_MAP_UNPACK_WITH_CALL is slow

2016-08-25 Thread STINNER Victor

STINNER Victor added the comment:

See also issue #27845: "Optimize update_keyword_args() function".

--
nosy: +haypo

___
Python tracker 

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



[issue27810] Add METH_FASTCALL: new calling convention for C functions

2016-08-25 Thread STINNER Victor

STINNER Victor added the comment:

I changed the dependency to the issue #27830 "Add _PyObject_FastCallKeywords(): 
avoid the creation of a temporary dictionary for keyword arguments" which 
itself depends on the issue #27213 "Rework CALL_FUNCTION* opcodes".

--
dependencies: +Add _PyObject_FastCallKeywords(): avoid the creation of a 
temporary dictionary for keyword arguments -_PyObject_FastCall(): add support 
for keyword arguments

___
Python tracker 

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



[issue27830] Add _PyObject_FastCallKeywords(): avoid the creation of a temporary dictionary for keyword arguments

2016-08-25 Thread STINNER Victor

Changes by STINNER Victor :


--
dependencies: +Rework CALL_FUNCTION* opcodes

___
Python tracker 

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



[issue27830] Add _PyObject_FastCallKeywords(): avoid the creation of a temporary dictionary for keyword arguments

2016-08-25 Thread STINNER Victor

Changes by STINNER Victor :


--
title: Add _PyObject_FastCallKeywords(): pass keyword arguments as (key, value) 
pairs -> Add _PyObject_FastCallKeywords(): avoid the creation of a temporary 
dictionary for keyword arguments

___
Python tracker 

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



[issue27830] Add _PyObject_FastCallKeywords(): pass keyword arguments as (key, value) pairs

2016-08-25 Thread STINNER Victor

STINNER Victor added the comment:

> New changeset ffcfa4f005a3 by Victor Stinner in branch 'default':
> Issue #27830: Revert, remove _PyFunction_FastCallKeywords()
> https://hg.python.org/cpython/rev/ffcfa4f005a3

I'm sorry, I misunderstood Serhiy's comment. I understood that Serhiy proposed 
to reuse the current format "PyObject **stack, int nargs, int nkwargs", but in 
fact he proposes something new in the issue #27213.

IMO the issue #27213 can be a major enhancement for Python 3.6. I prefer to 
wait until the issue #27213 is implemented (that we agreed on the new format), 
before working again on _PyObject_FastCallKeywords().

--

___
Python tracker 

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



[issue27830] Add _PyObject_FastCallKeywords(): pass keyword arguments as (key, value) pairs

2016-08-25 Thread Roundup Robot

Roundup Robot added the comment:

New changeset ffcfa4f005a3 by Victor Stinner in branch 'default':
Issue #27830: Revert, remove _PyFunction_FastCallKeywords()
https://hg.python.org/cpython/rev/ffcfa4f005a3

--

___
Python tracker 

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



[issue23702] docs.python.org/3/howto/descriptor.html still refers to "unbound methods"

2016-08-25 Thread Gregory P. Smith

Changes by Gregory P. Smith :


--
nosy: +gregory.p.smith
priority: normal -> high

___
Python tracker 

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



[issue27768] ssl: add public API for IA-32 processor capabilities vector

2016-08-25 Thread Gregory P. Smith

Gregory P. Smith added the comment:

The processor capabilities vector is not the API you want.

What you want is an API to ask the ssl library about characteristics of 
algorithm implementations it will be using.

Those are not the same thing.

If we want to expose processor capabilities as a library function it should not 
be done in the ssl module.  That information belongs in the platform module.  
And doing so should not require a third party library such as OpenSSL.  
Querying capabilities is a very simple instruction and every platform 
architecture specific C macros to do it.

--

___
Python tracker 

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



Re: Something wrong with the PIP, lots of friend have the same problem

2016-08-25 Thread Piet van Oostrum
Wentao Liang  writes:

> even though I try to upgrade PIP[cid:beb9e7c5-7d98-4506-ba67-9e67890edec1]
>
> 
> From: Wentao Liang
> Sent: Sunday, 21 August 2016 4:35:31 PM
> To: python-list@python.org
> Subject: Something wrong with the PIP, lots of friend have the same problem
>
>
> [cid:1c20248f-a678-40c0-9563-da4f8a1ef3bd]
> Is it the problem from PIP itself, or I used it in a wrong way? []
>
> Looking forwards to your reply!
>
> Thank you
>
> Wentao Liang

Without more information it is difficult to say. What command did you use and 
what was the result?

[Maybe you tried to include images in your post/mail but they did not come 
through. Just copy/paste the text.]
-- 
Piet van Oostrum 
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-08-25 Thread Christian Heimes

Christian Heimes added the comment:

OpenSSL 1.1.0 final was released a couple of hours ago. One test is failing 
because it uses 3DES. 1.1.0 has 3DES disabled by default.

--

___
Python tracker 

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



[issue26638] Avoid warnings about missing CLI options when building documentation

2016-08-25 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Thank you, that worked -- and should have been documented in the help output.  
All the sphinx dependencies were inequalities, and rebuilding worked.

The devguide only says "You are expected to have installed a recent version of 
Sphinx on your system or in a virtualenv,".  Could we add

"We currently recommend 'python -m pip install sphinx==1.3.6' as the easiest 
way to install and the best version for most people to install.  See 
https://bugs.python.org/issue26638 for why."

(I am assuming that pip works on all systems, not just Windows.)  The sentence 
finishes with "so that the Makefile can find the sphinx-build command."  On 
Windows. this is most easily done by installing Sphinx with a Python version 
that was added to PATH when installed.

--

___
Python tracker 

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



[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-08-25 Thread Chi Hsuan Yen

Changes by Chi Hsuan Yen :


--
nosy: +Chi Hsuan Yen

___
Python tracker 

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



[issue27855] 2to3: Wrong code output w/ has_key without trailing space

2016-08-25 Thread E Rippey

E Rippey added the comment:

I have one line change to "Lib/lib2to3/fixes/fix_has_key.py" that will resolve 
this issue.  Would a patch be accepted?

It doesn't seem like the input is unusually contorted.

--
status: closed -> open

___
Python tracker 

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



[issue27859] argparse - subparsers does not retain namespace

2016-08-25 Thread Eric N. Vander Weele

Changes by Eric N. Vander Weele :


--
nosy: +ericvw

___
Python tracker 

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



[issue27863] multiple issues in _elementtree module

2016-08-25 Thread Eric N. Vander Weele

Changes by Eric N. Vander Weele :


--
nosy: +ericvw

___
Python tracker 

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



[issue25878] CPython on Windows builds with /W3, not /W4

2016-08-25 Thread Jim Jewett

Jim Jewett added the comment:

Is there a way to document why certain warnings are being suppressed, in case 
someone wants to revisit the suppression later?

--
nosy: +Jim.Jewett

___
Python tracker 

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



[issue27850] Remove 3DES from cipher list (sweet32 CVE-2016-2183)

2016-08-25 Thread Christian Heimes

Christian Heimes added the comment:

Jim, https://docs.python.org/3/library/ssl.html#ssl.SSLContext.set_ciphers

>>> ctx = ssl.create_default_context()
>>> ctx.set_ciphers('HIGH:+3DES:!MD5')

Please note that OpenSSL 1.1 will remove 3DES from default builds. You will 
have to build your own OpenSSL and re-compile Python in order to use 3DES with 
OpenSSL 1.1.

--

___
Python tracker 

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



[issue27846] Base64 expansion factor is 4 to 3, not 6 to 4

2016-08-25 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Agreed with David.

--

___
Python tracker 

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



[issue27846] Base64 expansion factor is 4 to 3, not 6 to 4

2016-08-25 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +pitrou

___
Python tracker 

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



[issue27852] itertools -> flatten_all()

2016-08-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

In proposed implementation str and bytes are not flattened. What about 
bytearray? array.array? memoryview? For different tasks they can be considered 
atomic or as collections. There are such much task specific details and the 
implementation is such simple, that I think there is no need add this function 
in itertools. And due to this details it may be not worth to add it as a recipe.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue27425] Tests fail because of git's newline preferences on Windows

2016-08-25 Thread Jim Jewett

Jim Jewett added the comment:

I think if the test is ensuring one line-ending type, then there should be 
another test ensuring the other... but I think it would be best if there were a 
single test file that had both types of line-endings, just to ensure that the 
code doesn't cheat by reading only the first line and assuming that the rest of 
the data is consistent.

--
nosy: +Jim.Jewett

___
Python tracker 

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



[issue27414] http.server.BaseHTTPRequestHandler inconsistence with Content-Length value

2016-08-25 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy:  -pitrou

___
Python tracker 

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



[issue27861] sqlite3 type confusion and multiple frees

2016-08-25 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue27858] Add identity function to functools

2016-08-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

See issue1673203, issue11011.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue27850] Remove 3DES from cipher list (sweet32 CVE-2016-2183)

2016-08-25 Thread Donald Stufft

Donald Stufft added the comment:

It's not a recompile but it's not a configuration file either, it's a Python 
level API you can call when you're creating a connection to specify what 
ciphers you want to allow for that connection.

--

___
Python tracker 

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



[issue27850] Remove 3DES from cipher list (sweet32 CVE-2016-2183)

2016-08-25 Thread Jim Jewett

Jim Jewett added the comment:

What does overriding to put it back require?

Does it require a re-compile, or can it be done via a config file?

Taking it out of the default set sounds reasonable, but requiring a recompile 
for people who want to retain backwards compatibility strikes me as too much, 
particularly for a maintenance release.

--
nosy: +Jim.Jewett

___
Python tracker 

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



[issue27860] Improvements to ipaddress module

2016-08-25 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +ncoghlan, serhiy.storchaka

___
Python tracker 

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



[issue27863] multiple issues in _elementtree module

2016-08-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you for your report tehybel.

--
assignee:  -> serhiy.storchaka
nosy: +serhiy.storchaka
stage:  -> needs patch

___
Python tracker 

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



[issue27863] multiple issues in _elementtree module

2016-08-25 Thread SilentGhost

Changes by SilentGhost :


--
nosy: +eli.bendersky, scoder
type:  -> behavior

___
Python tracker 

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



[issue27858] Add identity function to functools

2016-08-25 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I believe this has been previously discussed and declined.

--
nosy: +rhettinger

___
Python tracker 

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



[issue27863] multiple issues in _elementtree module

2016-08-25 Thread tehybel

New submission from tehybel:

I'll describe 7 issues in the /Modules/_elementtree.c module here. They
include multiple use-after-frees, type confusions and instances of
out-of-bounds array indexing.



Issue 1: use-after-free in element_get_text

The problematic code looks like this:

LOCAL(PyObject*)
element_get_text(ElementObject* self)
{ 
/* return borrowed reference to text attribute */

PyObject* res = self->text;

if (JOIN_GET(res)) { 
res = JOIN_OBJ(res);
if (PyList_CheckExact(res)) {
res = list_join(res);
if (!res)
return NULL;
self->text = res;
}
}

return res;
}

As we can see, if res is a list, we call list_join with res, which is
self->text. list_join will decrease self->text's reference count. When that
happens, arbitrary python code can run. If that code uses self->text, a
use-after-free occurs.

PoC (Proof-of-Concept segfaulting script):

---

import _elementtree as et

class X(str):
def __del__(self):
print(elem.text)

b = et.TreeBuilder()
b.start("test")
b.data(["", X("")])
b.start("test2")

elem = b.close()
print(elem.text)

---


Issue 2: use-after-free in element_get_tail

The same type of issue also exists in element_get_tail and should be fixed
there, too.



Issue 3: type confusion in elementiter_next

The function elementiter_next iterates over a tree consisting of elements.
Each element has an array of children. 

Before doing any casts, most of the elementtree code is careful to check that
these children are, indeed, elements; that is, that their type is correct. The
problem is that elementiter_next does not validate these child objects before
performing a cast. Here is the relevant line:

elem = (ElementObject *)cur_parent->extra->children[child_index];

If the child is not an element, a type confusion occurs. Here's a PoC:

-

import _elementtree as et

state = {
"tag": "tag",
"_children": [1,2,3],
"attrib": "attr",
"tail": "tail",
"text": "text",
}

e = et.Element("ttt")
e.__setstate__(state)

for x in e.iter():
print(x)

-



Issue 4: array-out-of-bounds indexing in element_subscr

This issue occurs when taking the subscript of an element. This is done using
the element_subscr function. The function calls PySlice_GetIndicesEx:

if (PySlice_GetIndicesEx(item,
self->extra->length,
, , , ) < 0) {
return NULL; 
}

The problem is that to evaluate the indices, PySlice_GetIndicesEx might call
back into python code. That code might cause the element's self->extra->length
to change. If this happens, the variables "start", "stop" and "step" might no
longer be appropriate.

The code then uses these variables for array indexing:

for (cur = start, i = 0; i < slicelen;
 cur += step, i++) {
PyObject* item = self->extra->children[cur]; 
...
}

But this could go out of bounds and interpret arbitrary memory as a PyObject.
Here's a PoC that reproduces this:

---

import _elementtree as et

class X:
def __index__(self):
e[:] = []
return 1

e = et.Element("elem")
for _ in range(10):
e.insert(0, et.Element("child"))

print(e[0:10:X()])

---

Running it results in a segfault:

(gdb) r ./poc14.py
Starting program: /home/xx/Python-3.5.2/python ./poc14.py

Program received signal SIGSEGV, Segmentation fault.
0x0049f933 in PyObject_Repr (v=0x768af058) at Objects/object.c:471
471 if (Py_TYPE(v)->tp_repr == NULL)
(gdb) print *v
$37 = {_ob_next = 0xdbdbdbdbdbdbdbdb, _ob_prev = 0xdbdbdbdbdbdbdbdb, ob_refcnt 
= 0xdbdbdbdbdbdbdbdc,
  ob_type = 0xdbdbdbdbdbdbdbdb}

As we can see, "v" is freed memory with arbitrary contents.



Issue 5: array-out-of-bounds indexing in element_ass_subscr

A separate issue of the same type, also due to a call to PySlice_GetIndicesEx,
exists in element_ass_subscr. Here's a proof-of-concept script for that:

---

import _elementtree as et

class X:
def __index__(self):
e[:] = []
return 1

e = et.Element("elem")
for _ in range(10):
e.insert(0, et.Element("child"))

e[0:10:X()] = []

---

To fix these, I believe we could check whether self->extra->length changed
after calling PySlice_GetIndicesEx, and bail out if so. (You can grep the
codebase for "changed size during iteration" for examples of some similarish
cases.)





Issue 6: use-after-free in treebuilder_handle_start

In the function treebuilder_handle_start we see these lines:

if (treebuilder_set_element_text(self->last, self->data))
return NULL;

Here self->last is the most recent element, and we are setting its text to
self->data. This assignment happens via the function
treebuilder_set_element_text which in turn calls
treebuilder_set_element_text_or_tail. There, if the element self->last is not
an exact instance of Element_Type, we run these 

[issue27859] argparse - subparsers does not retain namespace

2016-08-25 Thread SilentGhost

Changes by SilentGhost :


--
stage:  -> needs patch
versions:  -Python 3.2, Python 3.3, Python 3.4

___
Python tracker 

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



[issue27862] Make urllib.parse runnable as a script

2016-08-25 Thread SilentGhost

SilentGhost added the comment:

Guido doesn't like the idea in general[0].

[0] https://bugs.python.org/issue26488#msg273329

--
nosy: +SilentGhost
resolution:  -> rejected
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



[issue27860] Improvements to ipaddress module

2016-08-25 Thread SilentGhost

Changes by SilentGhost :


--
nosy: +pmoody
stage:  -> patch review

___
Python tracker 

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



[issue27862] Make urllib.parse runnable as a script

2016-08-25 Thread EungJun Yi

New submission from EungJun Yi:

It would be nice if urllib.prase runnable as a script so I can easily parse 
urls in command line or shell script.

I have attached a patch.

--
components: Library (Lib)
files: 0001-Make-urllib.parse-runnable-as-a-script.patch
keywords: patch
messages: 273660
nosy: EungJun.Yi
priority: normal
severity: normal
status: open
title: Make urllib.parse runnable as a script
type: enhancement
versions: Python 3.5
Added file: 
https://bugs.python.org/file44226/0001-Make-urllib.parse-runnable-as-a-script.patch

___
Python tracker 

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



Parlez-vous Python?

2016-08-25 Thread breamoreboy
Well the language certainly is getting mentioned all over the place 
https://yougov.co.uk/news/2016/08/23/parlez-vous-python/

Kindest regards.

Mark Lawrence.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27861] sqlite3 type confusion and multiple frees

2016-08-25 Thread tehybel

New submission from tehybel:

The first issue is a type confusion which resides in the sqlite3 module, in the
file connection.c. The function pysqlite_connection_cursor takes an optional
argument, a factory callable:

if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", kwlist,
 )) {
return NULL;
}

If the factory callable is given, it is called to initialize a cursor:

cursor = PyObject_CallFunction(factory, "O", self);

After this the cursor, which is a PyObject *, is cast directly to a
pysqlite_Cursor without performing any type checking:

if (cursor && self->row_factory != Py_None) {
Py_INCREF(self->row_factory);
Py_XSETREF(((pysqlite_Cursor *)cursor)->row_factory, self->row_factory);
}

Here is a small script which is tested on Python-3.5.2, 64-bit, with
--with-pydebug enabled:

--- begin script ---

import sqlite3

conn = sqlite3.connect('poc2.db')
conn.row_factory = 12
conn.cursor(lambda x: "A"*0x1)

--- end script ---


When run, this produces a segfault:

(gdb) r ./poc2.py

Program received signal SIGSEGV, Segmentation fault.
0x76496ad8 in pysqlite_connection_cursor (self=0x768cc370, 
args=, kwargs=)
at /home/xx/Python-3.5.2/Modules/_sqlite/connection.c:322
warning: Source file is more recent than executable.
322 Py_XSETREF(((pysqlite_Cursor *)cursor)->row_factory, 
self->row_factory);
(gdb) p cursor
$13 = (PyObject *) 0xa46b90
(gdb) p self->row_factory
$14 = (PyObject *) 0x8d05f0 
(gdb) x/3i $pc
=> 0x76496ad8 : movrax,QWORD PTR 
[rdi+0x10]
   0x76496adc : subrax,0x1
   0x76496ae0 : movQWORD PTR 
[rdi+0x10],rax
(gdb) p $rdi
$15 = 0x4141414141414141

An arbitrary word in memory is decremented.


--


The second issue exists in the function pysqlite_connection_set_isolation_level
which resides in /Modules/_sqlite/connection.c. It can result in memory getting
freed multiple times.

The problem is that the variable self->isolation_level is not cleared before
being DECREF'd.

The code looks like this:

static int pysqlite_connection_set_isolation_level(pysqlite_Connection* 
self, PyObject* isolation_level)
{
...
Py_XDECREF(self->isolation_level);
...
}

This call to Py_XDECREF can trigger an arbitrary amount of python code, e.g. via
self->isolation_level's __del__ method. That code could then call 
pysqlite_connection_set_isolation_level again, which would trigger another
Py_XDECREF call on the same self->isolation_level, which can thus be freed an
arbitrary number of times.

One way to fix this is to use Py_CLEAR instead.

Here's a proof-of-concept script which results in a segfault here:

--- begin script ---

import sqlite3

class S(str):
def __del__(self):
conn.isolation_level = S("B")

conn = sqlite3.connect('poc6.db')
conn.isolation_level = S("A")
conn.isolation_level = ""

--- end script ---

When run it segfaults here, with Python-3.5.2 and --with-pydebug enabled:

(gdb) r ./poc6.py
Starting program: /home/xx/Python-3.5.2/python ./poc6.py

Program received signal SIGSEGV, Segmentation fault.
_Py_ForgetReference (op=op@entry=0x76d81b80) at Objects/object.c:1757
1757if (op ==  ||
(gdb) bt
#0  _Py_ForgetReference (op=op@entry=0x76d81b80) at Objects/object.c:1757
#1  0x0049f8c0 in _Py_Dealloc (op=0x76d81b80) at 
Objects/object.c:1785
#2  0x0046ced8 in method_dealloc (im=im@entry=0x77f25de8) at 
Objects/classobject.c:198
#3  0x0049f8c5 in _Py_Dealloc (op=op@entry=0x77f25de8) at 
Objects/object.c:1786
...

--
components: Extension Modules
messages: 273659
nosy: ghaering, tehybel
priority: normal
severity: normal
status: open
title: sqlite3 type confusion and multiple frees
versions: Python 2.7, Python 3.5

___
Python tracker 

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



[issue27861] sqlite3 type confusion and multiple frees

2016-08-25 Thread Berker Peksag

Changes by Berker Peksag :


--
nosy: +berker.peksag
stage:  -> needs patch
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



[issue25847] CPython not using Visual Studio code analysis!

2016-08-25 Thread Christian Heimes

Christian Heimes added the comment:

Coverity Scan has two steps. In the first step the code is compiled with the 
coverity tool chain. It's a wrapper around the preprocessor and compiler. Next 
up the result is uploaded and analyzed by a service.

So yes, the project needs to be build before it can be analyzed.

--

___
Python tracker 

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



[issue27425] Tests fail because of git's newline preferences on Windows

2016-08-25 Thread Emanuel Barry

Changes by Emanuel Barry :


Added file: https://bugs.python.org/file44225/fix_newlines_2.patch

___
Python tracker 

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



[issue27425] Tests fail because of git's newline preferences on Windows

2016-08-25 Thread Emanuel Barry

Emanuel Barry added the comment:

Whoops, turns out I was using the wrong approach for binary files. Here come 
add_gitattributes_2.patch and fix_newlines_2.patch (thanks Zachary for pointing 
this out).

--
Added file: https://bugs.python.org/file44224/add_gitattributes_2.patch

___
Python tracker 

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



[issue26638] Avoid warnings about missing CLI options when building documentation

2016-08-25 Thread Zachary Ware

Zachary Ware added the comment:

The syntax is ` install ""`, so in this case 
'pip install "Sphinx==1.3.6"` (or `pip install "Sphinx<1.4"`) should do it for 
you.  That ought to also take care of downgrading any other packages that need 
it (though I don't think there are any), or at least tell you which ones should 
be downgraded and to what.

I'm not sure why there are both `pip list` and `pip freeze`, but `pip freeze` 
is the one that outputs usable syntax for a requirement specifier.

--

___
Python tracker 

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



Re: Alternatives to XML?

2016-08-25 Thread Peter Otten
Frank Millman wrote:

>> As you have to keep the "<", why bother?
> 
> If you mean why don't I convert the '<' to '', the answer is that I do
> - I just omitted to say so. However, explicit is better than implicit :-)

Doesn't that make the XML document invalid or changes it in an irreversible 
way? How would you know whether

""

started out as

""

or

"bar/>"

?

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27860] Improvements to ipaddress module

2016-08-25 Thread Moritz Sichert

New submission from Moritz Sichert:

This patch fixes the following minor issues with the ipaddress module:

- Removed unused property _BaseV4._valid_mask_octets
- Removed unused methods _BaseV4._is_valid_netmask() and _BaseV4._is_hostmask()
- Replaced several calls to superclass constructors by super()

It also refactors the constructors of IPv4Network, IPv4Interface, IPv6Network, 
and IPv6Interface.
They all now use the new method _get_addr_prefix_tuple() to parse the argument. 
It now matches the following sentence of the documentation of IPv4/6Interface:
"The meaning of address is as in the constructor of IPv4Network".

Additionally they now also accept a bytes or an IPv4/6Address object 
representing a netmask (or a hostmask [only IPv4]) as second element of an 
address/netmask tuple. This makes it easier to work with C-APIs that provide 
netmasks only as bytes object.

This patch does not try to solve issue 27683.

--
components: Library (Lib)
files: ipaddress-improvement.patch
keywords: patch
messages: 273655
nosy: moritzs
priority: normal
severity: normal
status: open
title: Improvements to ipaddress module
type: enhancement
versions: Python 3.6
Added file: https://bugs.python.org/file44223/ipaddress-improvement.patch

___
Python tracker 

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



[issue27859] argparse - subparsers does not retain namespace

2016-08-25 Thread Nick Papior

New submission from Nick Papior:

Using argparse does not retain the Namespace variable across sub-parsers.

This prohibits customization of Actions due to "upper" level arguments not 
being stored in the namespace passed to the sub-parsers.

Hence, one may not create different sub-parsers which depend on an upper level 
flag.

The reason is the subparser command:
subnamespace, arg_strings = parser.parse_known_args(arg_strings, None)

Which by default passes `None` as the namespace argument.

A simple patch would be to copy the original namespace, which may then be 
altered. And subsequently restored, based on changes to that namespace.

--
components: Library (Lib)
files: argparse_subspacenamespace.py
messages: 273654
nosy: Nick Papior
priority: normal
severity: normal
status: open
title: argparse - subparsers does not retain namespace
type: enhancement
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6
Added file: https://bugs.python.org/file44222/argparse_subspacenamespace.py

___
Python tracker 

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



[issue25847] CPython not using Visual Studio code analysis!

2016-08-25 Thread Steve Dower

Steve Dower added the comment:

Does it only check built code? I thought it would statically analyze 
everything? Is MS_WINDOWS code excluded, because that would explain why it 
"misses" issues.

--

___
Python tracker 

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



Re: Alternatives to XML?

2016-08-25 Thread Frank Millman

"Peter Otten"  wrote in message news:npmti0$qvu$1...@blaine.gmane.org...


Frank Millman wrote:


> At the risk of disappointing some of you, this is how I am going to 
> proceed.



'Tis too late for me to stop ;)


> The problem that prompted this thread was the issue of storing '<' and 
> '>' in attributes. I have come up with a simple workaround - pass the 
> XML through a function between the database and the gui, converting from 
> ''  to '>' in one direction, and back to '' in the other. It 
> works.



As you have to keep the "<", why bother?


If you mean why don't I convert the '<' to '', the answer is that I do - 
I just omitted to say so. However, explicit is better than implicit :-)


> If I ever get my project to the point where I need to move it to the 
> front, I will know that I am getting somewhere!


At that point you may also look at my messy/buggy/incomplete attempt to 
convert between xml and python:


[snip some impressive code]

Wow - that is impressive! I don't know if I will go that route, but I have 
kept a copy and will study it closely when I have time.


Many thanks

Frank


--
https://mail.python.org/mailman/listinfo/python-list


[issue27425] Tests fail because of git's newline preferences on Windows

2016-08-25 Thread Emanuel Barry

Emanuel Barry added the comment:

Here are three patches for this:

- add_gitattributes_1.patch adds `.gitattributes`, with all the newline 
preferences in `.hgeol` (with the exception of the "native" rule at the end, 
which in git is the default newline preference).
- fix_newlines_1.patch fixes test_sax to properly handle CRLF (since *.xml 
files may have either LF or CRLF), as well as a single batch file which wasn't 
using CRLF line endings for some reason.
- test_random_warning_1.patch is somewhat unrelated, but it makes sure that 
failures in the `pickle.load` call no longer show ResourceWarnings on stderr.

The two tests which used to fail no longer do so. Maybe 
add_gitattributes_1.patch should be backported to 2.7, but probably not the 
other ones.

--
keywords: +patch
stage:  -> patch review
versions:  -Python 3.5
Added file: https://bugs.python.org/file44219/add_gitattributes_1.patch

___
Python tracker 

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



[issue27425] Tests fail because of git's newline preferences on Windows

2016-08-25 Thread Emanuel Barry

Changes by Emanuel Barry :


Added file: https://bugs.python.org/file44221/test_random_warning_1.patch

___
Python tracker 

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



[issue27425] Tests fail because of git's newline preferences on Windows

2016-08-25 Thread Emanuel Barry

Changes by Emanuel Barry :


Added file: https://bugs.python.org/file44220/fix_newlines_1.patch

___
Python tracker 

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



[issue23746] sysconfg.is_python_build() is buggy

2016-08-25 Thread Roundup Robot

Roundup Robot added the comment:

New changeset bf51f1f3569a by Vinay Sajip in branch '3.5':
Issue #23746: Clarified is_python_build() documentation.
https://hg.python.org/cpython/rev/bf51f1f3569a

New changeset a0a7c5b1af97 by Vinay Sajip in branch 'default':
Closes #23746: merged update from 3.5.
https://hg.python.org/cpython/rev/a0a7c5b1af97

--
nosy: +python-dev
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



[issue1100942] Add datetime.time.strptime and datetime.date.strptime

2016-08-25 Thread Mark Dickinson

Changes by Mark Dickinson :


--
nosy:  -mark.dickinson

___
Python tracker 

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



Re: Alternatives to XML?

2016-08-25 Thread Peter Otten
Frank Millman wrote:

> "Frank Millman"  wrote in message news:nplvvl$ci2$1...@blaine.gmane.org...
> 
>> Hi all
> 
>> I have mentioned in the past that I use XML for storing certain
>> structures 'off-line', and I got a number of comments urging me to use
>> JSON or YAML instead.
> 
>> Can anyone offer an alternative which is closer to my original intention?
> 
> Thanks to Chris and Peter for their additional input - much appreciated.
> 
> At the risk of disappointing some of you, this is how I am going to
> proceed.

'Tis too late for me to stop ;)

> 1. I am writing tools to make it easier to develop business systems, and
> at the same time I am developing a business system. As the tools mature I
> am spending more time on the system, but as I work on the system I am
> finding shortcomings in the tools, so I am bouncing between the two at the
> moment.
> 
> 2. There are many areas of the tools which other users will find confusing
> at first and will require explanations and documentation. I am more than
> ready to make changes based on the reactions I get. The subject of this
> thread is one small part of this.
> 
> 3. My immediate priority is to finish the business system, get it out
> there, and get feedback. Hopefully other users will then start dabbling
> with the tools and provide feedback there as well.
> 
> 4. As I have said already, for good or ill, I am comfortable with my
> current use of XML, so I do not have a pressing need to change to anything
> else. The problem that prompted this thread was the issue of storing '<'
> and '>' in attributes. I have come up with a simple workaround - pass the
> XML through a
> function between the database and the gui, converting from ''  to '>'
> in one direction, and back to '' in the other. It works.

As you have to keep the "<", why bother?
 
> 5. I have learned a lot from this thread, but for now it is staying in the
> back of my mind. If I ever get my project to the point where I need to
> move it to the front, I will know that I am getting somewhere!

At that point you may also look at my messy/buggy/incomplete attempt to 
convert between xml and python:

$ cat convert.py 
import ast
from xml.etree import ElementTree as etree

XML = """\

  

  

  
  

  

  

"""

tree = etree.fromstring(XML)

TARGETS = {
"$None": "None",
}
RTARGETS = {
None: "$None",
}
assert len(RTARGETS) == len(TARGETS)

OPS = {
"is_not": "is not",
}
ROPS = {ast.IsNot: "is_not"}
assert len(ROPS) == len(OPS)

NAMES = {"on_insert", "not_exists"}
FUNCS = {"auto_gen"}


def getchildren(elem):
yield from elem.getchildren()


def to_python(elem, indent=""):
# XXX build an AST rather than source code.
if elem.tag == "compare":
yield "{}if {} {} {}:".format(
indent,
elem.attrib["src"],
OPS[elem.attrib["op"]],
TARGETS[elem.attrib["tgt"]]
)
[child] = getchildren(elem)
yield from to_python(child, indent)
elif elem.tag in NAMES:
yield "{}if {}:".format(indent, elem.tag)
for child in getchildren(elem):
yield from to_python(child, indent + "")
elif elem.tag == "case":
for child in getchildren(elem):
yield from to_python(child, indent + "")
elif elem.tag == "literal":
yield "{}value = {!r}".format(indent, elem.attrib["value"])
elif elem.tag in FUNCS:
yield "{}auto_gen({})".format(indent, elem.attrib["args"])
else:
raise ValueError("Unknown tag {!r}".format(elem.tag))


def dotted(node):
if isinstance(node, ast.Attribute):
return dotted(node.value) + "." + node.attr
else:
return node.id


def to_xml(python):
module = ast.parse(python)
[body] = module.body
root = etree.Element("case")

def _convert(node, parent):
if isinstance(node, ast.If):
test = node.test
if isinstance(test, ast.Compare):
compare = etree.Element("compare")
[op] = test.ops
compare.attrib["src"] = dotted(test.left)
compare.attrib["op"] = ROPS[type(op)]
right = test.comparators[0].value
compare.attrib["tgt"] = RTARGETS[right]
case = etree.Element("case")
compare.append(case)
parent.append(compare)
for child in node.body:
_convert(child, case)
elif isinstance(test, ast.Name):
ename = etree.Element(test.id)
parent.append(ename)
for child in node.body:
_convert(child, ename)
elif isinstance(node, ast.Expr):
evalue = node.value
evalue.func.id
invoke = etree.Element(evalue.func.id)

[issue23105] os.O_SHLOCK and os.O_EXLOCK are not available on Linux

2016-08-25 Thread Vinay Sajip

Vinay Sajip added the comment:

The existing docs have a section "These constants are GNU extensions and not 
present if they are not defined by the C library."

There could be a corresponding section for BSD extensions to which O_EXLOCK and 
O_SHLOCK are moved, or the word "GNU" can removed from the existing section and 
these two flags moved to it. How does that sound? My preference would be for 
the latter.

--
nosy: +vinay.sajip

___
Python tracker 

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



[issue23746] sysconfg.is_python_build() is buggy

2016-08-25 Thread Vinay Sajip

Vinay Sajip added the comment:

It's not *only* used in test - it's also used in third party libraries. For 
example, it's used in distlib (which is vendored by pip) to determine whether 
it's being run from a source build.

--
nosy: +vinay.sajip

___
Python tracker 

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



[issue27858] Add identity function to functools

2016-08-25 Thread R. David Murray

R. David Murray added the comment:

I agree with Steven, I don't think this is really worth it, but I wouldn't vote 
-1.  I suspect it won't get added, though, since a function I do want ('first') 
got rejected :)

--
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



[issue27858] Add identity function to functools

2016-08-25 Thread Jáchym Barvínek

Jáchym Barvínek added the comment:

Java offers an identity function:
https://docs.oracle.com/javase/8/docs/api/java/util/function/Function.html

2016-08-25 14:10 GMT+02:00 Steven D'Aprano :

>
> Steven D'Aprano added the comment:
>
> Just in case anyone else thinks this is a good idea, here's a patch.
>
> --
> keywords: +patch
> Added file: https://bugs.python.org/file44218/identity.patch
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue27855] 2to3: Wrong code output w/ has_key without trailing space

2016-08-25 Thread R. David Murray

Changes by R. David Murray :


--
title: 2to3: Wrong code output w/ has_key -> 2to3: Wrong code output w/ has_key 
without trailing space

___
Python tracker 

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



[issue27855] 2to3: Wrong code output w/ has_key

2016-08-25 Thread R. David Murray

R. David Murray added the comment:

I don't think it is necessary or reasonable to expect 2to3 to handle this.  It 
is a tool for the developer to use, so just clean up the input.

--
nosy: +r.david.murray
resolution:  -> rejected
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



[issue27858] Add identity function to functools

2016-08-25 Thread Steven D'Aprano

Steven D'Aprano added the comment:

Just in case anyone else thinks this is a good idea, here's a patch.

--
keywords: +patch
Added file: https://bugs.python.org/file44218/identity.patch

___
Python tracker 

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



[issue27858] Add identity function to functools

2016-08-25 Thread Steven D'Aprano

Steven D'Aprano added the comment:

I had a work mate make this exact same point literally yesterday. He asked me 
if Python had an identity function, and when I suggested just using `lambda x: 
x` he grouched that this wasn't sufficiently obvious enough as "identity" is 
self-explanatory.

(Perhaps for English speakers with a background in mathematics or functional 
programming.)

I'm not really convinced. Its easier to just write a lambda than to `from 
functools import identity`, and despite what my workmate thinks, "identity" is 
not self-evident. Consider that identity could also be a function that returns 
a person's identifying information. Think about the English usage of "identity 
theft" and "secret identity", rather than the mathematical meaning.

So I'm at best +0 on this suggestion.

--
nosy: +steven.daprano

___
Python tracker 

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



Re: Alternatives to XML?

2016-08-25 Thread Chris Angelico
On Thu, Aug 25, 2016 at 9:23 PM, Frank Millman  wrote:
>
> At the risk of disappointing some of you, this is how I am going to proceed.
>
> 4. As I have said already, for good or ill, I am comfortable with my current
> use of XML, so I do not have a pressing need to change to anything else. The
> problem that prompted this thread was the issue of storing '<' and '>' in
> attributes. I have come up with a simple workaround - pass the XML through a
> function between the database and the gui, converting from ''  to '>' in
> one direction, and back to '' in the other. It works.

Should be fine, as long as the actual XML file has  in it. It
won't disappoint me at all, if the XML file is (primarily) a transport
format between programs; just make sure it's always valid XML, rather
than some "XML-like" file structure. In a greenfield project, I would
advise strongly against this, but since you already have something to
work with, it's not worth changing everything up.

Know that every decision has consequences, and make your decisions
with open eyes. I'm not disappointed by someone who, with greater
knowledge of the situation and the likely consequences of various
choices, chooses something different from what I, from thousands of
miles away, recommended :)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27858] Add identity function to functools

2016-08-25 Thread Jáchym Barvínek

New submission from Jáchym Barvínek:

An identity function is sometimes useful in functional-style programming as a 
dummy or default value.

For example, we can sometimes see a pattern like this (e.g. in 
itertools.groupby):

def f(params, key=None):
  if key is None:
key = lambda x: x
  ...


However, if we had a canonical itentity function:

def identity(x):
  return x

we could instead write:

def f(params, key=identity):
  ...

and the intended use of the function f and it's functioning would be more 
obvious simply from it's signature, while also saving a little code. 

As zen of Python says: Explicit is better than implicit.

Of course, we can now write:

def f(params, key=lambda x: x):
  ...

but the reason why is not used is probably that it feels a bit awkward to more 
people than just me.

--
components: Library (Lib)
messages: 273643
nosy: Jáchym Barvínek
priority: normal
severity: normal
status: open
title: Add identity function to functools
type: enhancement
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



[issue27846] Base64 expansion factor is 4 to 3, not 6 to 4

2016-08-25 Thread Jens Jørgen Mortensen

Changes by Jens Jørgen Mortensen :


--
versions: +Python 3.5

___
Python tracker 

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



[issue27846] Base64 expansion factor is 4 to 3, not 6 to 4

2016-08-25 Thread Jens Jørgen Mortensen

Jens Jørgen Mortensen added the comment:

That would also be a solution.  Also, the sentence is not quite grammatically 
correct: "when space [is] expensive".

--
versions:  -Python 3.5

___
Python tracker 

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



Re: Holding until next value change

2016-08-25 Thread Arshpreet Singh
On Saturday, 20 August 2016 19:48:38 UTC+5:30, andrze...@gmail.com  wrote:
 
> prev = None
> for value in main_call():
> if value==prev:
> pass
> else:
> prev = value
> if prev>0:
> print('+v')
> elif prev<0:
> print('-v')
> else:
> print('0')

No it did'nt worked.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Alternatives to XML?

2016-08-25 Thread Frank Millman

"Frank Millman"  wrote in message news:nplvvl$ci2$1...@blaine.gmane.org...


Hi all


I have mentioned in the past that I use XML for storing certain structures 
'off-line', and I got a number of comments urging me to use JSON or YAML 
instead.



Can anyone offer an alternative which is closer to my original intention?


Thanks to Chris and Peter for their additional input - much appreciated.

At the risk of disappointing some of you, this is how I am going to proceed.

1. I am writing tools to make it easier to develop business systems, and at 
the same time I am developing a business system. As the tools mature I am 
spending more time on the system, but as I work on the system I am finding 
shortcomings in the tools, so I am bouncing between the two at the moment.


2. There are many areas of the tools which other users will find confusing 
at first and will require explanations and documentation. I am more than 
ready to make changes based on the reactions I get. The subject of this 
thread is one small part of this.


3. My immediate priority is to finish the business system, get it out there, 
and get feedback. Hopefully other users will then start dabbling with the 
tools and provide feedback there as well.


4. As I have said already, for good or ill, I am comfortable with my current 
use of XML, so I do not have a pressing need to change to anything else. The 
problem that prompted this thread was the issue of storing '<' and '>' in 
attributes. I have come up with a simple workaround - pass the XML through a 
function between the database and the gui, converting from ''  to '>' in 
one direction, and back to '' in the other. It works.


5. I have learned a lot from this thread, but for now it is staying in the 
back of my mind. If I ever get my project to the point where I need to move 
it to the front, I will know that I am getting somewhere!


Thanks again to all.

Frank


--
https://mail.python.org/mailman/listinfo/python-list


[issue27838] test_os.test_chown() random failure on "AMD64 FreeBSD CURRENT Debug 3.x" buildbot

2016-08-25 Thread STINNER Victor

STINNER Victor added the comment:

Hum, the test has a fail ratio somewhere near 1/5. It fails for 6 months,
maybe longer.

--

___
Python tracker 

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



Re: Alternatives to XML?

2016-08-25 Thread Chris Angelico
On Thu, Aug 25, 2016 at 5:13 PM, Frank Millman  wrote:
> "Chris Angelico"  wrote in message
> news:CAPTjJmof_sXqax0Ury5LsBEj7cdFv92WiWKbfvAC+bM=hwt...@mail.gmail.com...
>
>> Sounds to me like you have two very different concerns, then. My
>> understanding of "GUI" is that it's a desktop app running on the user's
>> computer, as opposed to some sort of client/server system - am I right?
>
>
> Not exactly, but the difference in not important, as you have got the
> essentials below spot on.

Cool. The essential difference, in this case, being where the edits
are happening.

> Absolutely. If an organisation running my system wants to be secure, they
> should keep the server in a locked room only accessible by a trusted system
> administrator.

Right. That saves a ton of effort for you - it's no longer about
malicious users.

>> Here's a very simple format, borrowing from RFC822 with a bit of Python
>> added:
>
>
> if: _param.auto_party_id != None
>if: on_insert
>value: =auto_gen(_param.auto_party_id)
>elif: not_exists
>value: 
>
> Getting close, but it is not *quite* that simple.
>
> For example, having isolated the LHS of the if clause, I process it
> something like this -
>
> if source.startswith("'"):
>source_value = source[1:-1]

I don't like this; if you're going to surround strings with quotes,
you either need some sort of escaping mechanism, or disallow the same
quote character from coming up inside. (At very least, demand that the
string ends with an apostrophe too, or you'll have a lot of VERY
confusing failures if someone omits the closing apostrophe. Make it an
instant error instead.)

> elif '.' in source:
>source_objname, source_colname = source.split('.', 1)
>source_record = caller.data_objects[source_objname]
>source_value = source_record.getval(source_colname)

Fair enough; your dot notation is restricted to "this column from this
thing", where a thing effectively identifies a table. Though I'm
beginning to get the idea that the snippet you're showing here has
elided all error checking - assuming that you actually do have that
checking in the real version.

> elif source == '$None':
>source_value = None
> elif source == '$True':
>source_value = True
> elif source == '$False':
>source_value = False

If you're looking for specific strings, you shouldn't need to adorn
them. Point of note: "None" is a peculiarly Python concept, so anyone
who's using it is going to need to understand its semantics from a
Python perspective. If None is significant to your code, it's probably
semantically important, and that might cause issues if anyone doesn't
know code. And if everyone who edits this file knows Python, well,
we're back to "why not just let them write in Python".

> elif source.startswith('int('):
>source_value = int(source[4:-1])

Hrm. This is where I'd move away from Python syntax. If you're only
allowing a scant few typecasts, I'd go instead for an SQL-like syntax
eg "some_value::int", or switch it around as "int::some_value", and
make it clearly NOT a function call. Otherwise, I'd have a very simple
"drop to Python" mode, which would be handled something like this:

elif source.startswith("="):
source_value = eval(source[1:])

> Anyway, you have isolated the essential issue. I need a DSL which is easy
> for a non-technical user to read/write, and easy to verify that it is
> achieving the desired result.

Yes; or, if not easy to verify the result, at least make it easy to
verify the syntax, even in the face of errors.

> I suspect that this is quite challenging whatever format I use. Up to now I
> have been using XML, and it works for me. As Rob pointed out, I have become
> too comfortable with it to be objective, but no-one has yet convinced me
> that the alternatives are any better. I may eventually end up with an
> additional layer that prompts the user through their requirement in 'wizard'
> style, and generates the underlying XML (or whatever) automatically.

That's one option. At that point, the storage format becomes opaque to
humans - it's just an interchange format between two programs. As
such, I would advocate the use of JSON.

Of course, you still need to build that UI, which is a lot of work.
You'll also have to have GUI controls on your wizard for every
possible option, which makes options very expensive (in contrast to a
textual language, in which options are far cheaper) - every user has
to see every option every time. So you have to strike a *very* careful
balance between expressiveness/power and simplicity, and it's entirely
possible to fall down on both fronts.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Alternatives to XML?

2016-08-25 Thread Peter Otten
Frank Millman wrote:

> "Chris Angelico"  wrote in message
> news:CAPTjJmof_sXqax0Ury5LsBEj7cdFv92WiWKbfvAC+bM=hwt...@mail.gmail.com...
> 
>> Sounds to me like you have two very different concerns, then. My
>> understanding of "GUI" is that it's a desktop app running on the user's
>> computer, as opposed to some sort of client/server system - am I right?
> 
> Not exactly, but the difference in not important, as you have got the
> essentials below spot on.
> 
> For the record, the server runs an HTTP server, and anyone on the LAN/WAN
> can access the system using a browser. Because the tables that define the
> database are stored in the database itself, there is no difference between
> a form that allows a user to capture an invoice, and a form that allows a
> user to modify a column definition. It is all controlled through
> permissions, but technically they are identical.
> 
>> 1) Malicious users, as I describe above, can simply mess with your code
>> directly, or bypass it and talk to the database, or anything. So you can
>> ignore them.
> 
> Absolutely. If an organisation running my system wants to be secure, they
> should keep the server in a locked room only accessible by a trusted
> system administrator.
> 
>> 2) Non-programmer users, without any sort of malice, want to be able to
>> edit these scripts but not be caught out by a tiny syntactic problem.
> 
> Now we are getting to the nitty-gritty.
> 
> [snip some good comments]
> 
>> Here's a very simple format, borrowing from RFC822 with a bit of Python
>> added:
> 
> if: _param.auto_party_id != None
> if: on_insert
> value: =auto_gen(_param.auto_party_id)
> elif: not_exists
> value: 
> 
> Getting close, but it is not *quite* that simple.
> 
> For example, having isolated the LHS of the if clause, I process it
> something like this -
> 
> if source.startswith("'"):
> source_value = source[1:-1]
> elif '.' in source:
> source_objname, source_colname = source.split('.', 1)
> source_record = caller.data_objects[source_objname]
> source_value = source_record.getval(source_colname)
> elif source == '$None':
> source_value = None
> elif source == '$True':
> source_value = True
> elif source == '$False':
> source_value = False
> elif source.startswith('int('):
> source_value = int(source[4:-1])

It may be a little more work, but whatever check you can think of for your 
XML can also be applied to a piece of Python code. For example the above 
might become

$ cat eval_source.py
import ast


def source_value_dot(source_objname, source_colname):
return "<{}.{}>".format(source_objname, source_colname)
# may become:
source_record = caller.data_objects[source_objname]
return source_record.getval(source_colname)


def get_source(node):
# Modeled after ast.literal_eval()

def _convert(node):
if isinstance(node, ast.Expression):
return _convert(node.body)
elif isinstance(node, ast.Str):
return node.s
elif isinstance(node, ast.Attribute):
if not isinstance(node.value, ast.Name):
raise ValueError("only one dot, please", node)
name = node.value.id
column = node.attr
return source_value_dot(name, column)
elif isinstance(node, ast.NameConstant):
return node.value
elif isinstance(node, ast.Num):
n = node.n
if not isinstance(n, int):
raise ValueError("only integers, please", node)
return n
else:
raise ValueError("oops", node)
return _convert(node)


EXAMPLES = """\
None
True
42
3.4
bar.baz
foo.bar.baz
'whatever.you.want'
""".splitlines()

for source in EXAMPLES:
e = ast.parse(source, mode="eval")
try:
result = get_source(e)
except ValueError as e:
result = "#error: {}".format(e.args[0])
print(source, "-->", result)

$ python3 eval_source.py 
None --> None
True --> True
42 --> 42
3.4 --> #error: only integers, please
bar.baz --> 
foo.bar.baz --> #error: only one dot, please
'whatever.you.want' --> whatever.you.want

Of course you could also use a slightly more general approach (use a 
whitelist of function names, feed dotted names to a function etc.), so that 
the resulting ast can safely be fed to exec().

Whatever you do, the most likely problem you may run into is annoyed users 
asking "This looks like Python, why can't I..."

> Anyway, you have isolated the essential issue. I need a DSL which is easy
> for a non-technical user to read/write, and easy to verify that it is
> achieving the desired result.
> 
> I suspect that this is quite challenging whatever format I use. Up to now
> I have been using XML, and it works for me. As Rob pointed out, I have
> become too comfortable with it to be objective, but no-one has yet
> convinced me that the alternatives are any better. I may eventually end up
> with an additional layer that prompts the user 

[issue27838] test_os.test_chown() random failure on "AMD64 FreeBSD CURRENT Debug 3.x" buildbot

2016-08-25 Thread koobs

koobs added the comment:

This appears to have spontaneously resolved itself after build #957 after many 
failures. For reference, other builders on the same host were failing as well:

AMD64 FreeBSD CURRENT Debug 3.5 (#567, #568)
AMD64 FreeBSD CURRENT Non-Debug 3.5 (#8, #9)

And possibly others (Didn't listed any that hadn't failed in the last 5 builds)

According to my (non-expert) reading of the code, the test skips (or is 
supposed to skip) unless group count of uid is > 1.

The group membership of the buildbot user this worker runs as is only 
'buildbot' and on that basis wouldn't a skip expected?

Open questions are:

1) Why/how did it suddenly *start* failing. (I cant see any relevant commits at 
or around the time)
2) Why/how did it suddenly stop failing (I made no worker/buildbot changes

Nosy vajrasky (original unit test creator) and Claudiu (who reviewed), who 
might be able to shine a light on what might be going on

--
nosy: +Claudiu.Popa, vajrasky

___
Python tracker 

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



[issue27833] Process is locked when try to execute Queue.put() inside

2016-08-25 Thread Xiang Zhang

Xiang Zhang added the comment:

Guni, the behaviour is not consistent since your code is not that 'right'. You 
can not expect a not 'right' snippet to behave correctly. You can do what the 
programming guide says:

[1] consuming all items before join
[2] call q.cancel_join_thread
[3] ignore prs1.join since it will be automatically joined

Choose one and then the behaviour would be consistent.

--

___
Python tracker 

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



[issue27833] Process is locked when try to execute Queue.put() inside

2016-08-25 Thread Guni

Guni added the comment:

Hi Eric,

The reason why I still think is a actually bug is because the behaviour is not 
consistent. When we write code we don't exactly know how much data we will put 
in the queue.

If this ticket is consider as not an actual bug it means that everybody has to 
make a check inside the process in order to predict what behaviour will happen.

Feel free to close the ticket if you think that's a feature not a bug.

Thanks

--
status: closed -> open

___
Python tracker 

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



Re: Knowing which thread had the GIL before

2016-08-25 Thread dieter
Julien Kauffmann  writes:
> ...
> Is there a way to know which thread had the GIL right before my
> profiling thread acquired it ? Perhaps through a C extension ? I've
> seen such profilers for Linux that take advantage of an ITIMER signal
> to do that. Sadly this is not an option on Windows.

As you have already suspected, you will likely need a C extension:
Python does (almost surely) not maintain a GIL history (not even a short
one containing only the previous GIL holder).

If you implement your monitoring thread (mostly) in C, there definitely
is a global interpreter variable which contains a thread identifier
for the thread currently holding the GIL.


> Any feedback or remark concerning my technique is also welcome.

It would be best if you could get informed when the GIL switches.
Almost surely, this is unsupported on Python level. But perhaps
on C level. I would check the (C) code for Python's GIL handling.

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27768] ssl: add public API for IA-32 processor capabilities vector

2016-08-25 Thread Antoine Pitrou

Antoine Pitrou added the comment:

If we wanted to expose such information, we would need to do it in a dedicated 
module (or in `os`) and provide something that doesn't restrict itself to two 
particular x86 flags.

requests can rely on a private attribute if they really want to.

--

___
Python tracker 

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



[issue27768] ssl: add public API for IA-32 processor capabilities vector

2016-08-25 Thread Christian Heimes

Christian Heimes added the comment:

Why? Other libraries like requests like to use the information, too.

--

___
Python tracker 

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



[issue27768] ssl: add public API for IA-32 processor capabilities vector

2016-08-25 Thread Antoine Pitrou

Antoine Pitrou added the comment:

The constants would have to be private, too. We really don't want to encourage 
other users to rely on them.

--

___
Python tracker 

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



[issue26488] hashlib command line interface

2016-08-25 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
resolution:  -> rejected
status: open -> closed

___
Python tracker 

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



[issue25847] CPython not using Visual Studio code analysis!

2016-08-25 Thread Christian Heimes

Christian Heimes added the comment:

+1, if somebody is able to find time. Coverity Scan checks only X86_64 Linux 
builds.

--

___
Python tracker 

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



[issue27852] itertools -> flatten_all()

2016-08-25 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee:  -> rhettinger
components: +Documentation
nosy: +rhettinger
priority: normal -> low

___
Python tracker 

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



  1   2   >