Re: Is there an idiom for this?

2015-12-24 Thread Paul Rubin
KP  writes:
> for config in cfg: 
> if config != 'c': 
> print config 
>
> Is there an idiom that combines the 'for...' & the 'if..' lines into one? 

Maybe you actually want

  print [config for config in cfg if config != 'c']

That prints all the relevant keys as a list, rather than one per line.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: unable to open IDLE for Python3.50rc1 on windows10 64bit AMD

2015-12-24 Thread Terry Reedy

On 12/24/2015 9:59 AM, eryk sun wrote:

On Thu, Dec 24, 2015 at 5:06 AM, Nicky Mac  wrote:


not sure what you mean by "my profile".
following your suggestion, looks normal:


I meant your profile directory, "C:\Users\Nick". But printing the
package path showed the problem is in your Python 3 installation
itself.


C:\Users\Nick> python -c "import importlib;
print(importlib.find_loader('idlelib').path)"
C:\Python\Python35\lib\idlelib\__init__.pyc


This file should not exist. Python 3 stores .pyc files in a
__pycache__ subdirectory. It won't even run "idlelib\__init__.pyc" if
"idlelib\__init__.py" exists, so your installation is incomplete and
damaged. I suggest that you uninstall Python 3.5 and then completely
remove "C:\Python\Python35" before reinstalling.


'python -m xyz', where xyz is a package name (directory on disk), runs 
xyx/__main__.py (or the xyz/__pycache__/__main__...34.py compiled 
version).  This file currently contains the following implementation, 
subject to change.


"""
IDLE main entry point

Run IDLE as python -m idlelib
"""
import idlelib.PyShell
idlelib.PyShell.main()
# This file does not work for 2.7; See issue 24212.

The errant __init__.pyc should not directly be a problem, but does 
indicate something wrong, such as 2.7 files mixed into your 3.5 install 
(__cache__ is *not* used in 2.7).  Based on my experience with this 
happening, you might try running chkdsk, from an elevated Command Prompt.


'python -m idlelib.idle' runs idlelib/idle.py (or the cached version) to 
mostly the same effect.   The alternate entry has adjustments so it 
works in an uninstalled development repository, while still working in 
an installation.


From a python program, 'import idlelib.idle' needed as 'import idlelib' 
would run idlelib/__init__.py, which is empty.


--
Terry Jan Reedy

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


[issue25942] subprocess.call SIGKILLs too liberally

2015-12-24 Thread Mike Pomraning

New submission from Mike Pomraning:

Python 3.3 introduces timeout support in subprocess.call, implemented by 
sending a SIGKILL if the Popen.wait is interrupted by a TimeoutExpired 
exception.

However, the "except" clause is too broad, and will, for instance, trigger on a 
KeyboardInterrupt.  For practical purposes, this means that sending a Ctrl-C to 
a python program before 3.3 sent a SIGINT to both the parent and 
subprocess.call()d child, whereas under 3.3+ sends a SIGINT _and_ a SIGKILL to 
the child.  The child will not be able to clean up appropriately.

For a real world example of this, see http://stackoverflow.com/q/34458583/132382

The fix is, I think, simply changing the clause to "except TimeoutExpired".  At 
least, that works for me.  See attached patch.

--
components: Library (Lib)
files: subprocess-call-py344-kill-only-on-timeout.patch
keywords: patch
messages: 256973
nosy: Mike Pomraning
priority: normal
severity: normal
status: open
title: subprocess.call SIGKILLs too liberally
type: behavior
versions: Python 3.3
Added file: 
http://bugs.python.org/file41407/subprocess-call-py344-kill-only-on-timeout.patch

___
Python tracker 

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



Re: can i subscribe python mailing list?

2015-12-24 Thread Cameron Simpson

On 24Dec2015 22:22, 우종민  wrote:

  i want to subscribe mailing list
  [1][IMG]


You can do that here:

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

Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


[issue25943] Integer overflow in _bsddb leads to heap corruption

2015-12-24 Thread Ned Williamson

New submission from Ned Williamson:

In function `_db_associateCallback` of the `_bsddb` module, associating two 
databases with a callback that returns a sufficiently large list will lead to 
heap corruption due an integer overflow on 32-bit Python.

>From `_bsddb.c`:
```
else if (PyList_Check(result))
{
char* data;
Py_ssize_t size;
int i, listlen;
DBT* dbts;

listlen = PyList_Size(result);

1.  dbts = (DBT *)malloc(sizeof(DBT) * listlen); ///sizeof(DBT) == 28 on my 
system, enough to overflow

2.  for (i=0; iassociate callback should be a list of strings.");
#else
"The list returned by DB->associate callback should be a list of bytes.");
#endif
PyErr_Print();
}

PyBytes_AsStringAndSize(
PyList_GetItem(result, i),
3.  , );

CLEAR_DBT(dbts[i]);
4.  dbts[i].data = malloc(size);  /* TODO, check this */

if (dbts[i].data)
{
5.  memcpy(dbts[i].data, data, size);
dbts[i].size = size;
dbts[i].ulen = dbts[i].size;
dbts[i].flags = DB_DBT_APPMALLOC;  /* DB will free */
}
else
{
PyErr_SetString(PyExc_MemoryError,
"malloc failed in _db_associateCallback (list)");
PyErr_Print();
}
}

CLEAR_DBT(*secKey);

secKey->data = dbts;
secKey->size = listlen;
secKey->flags = DB_DBT_APPMALLOC | DB_DBT_MULTIPLE;
retval = 0;
}
```

1. The multiplication in this line can overflow, allocating an undersized 
buffer.
2. This loop does not suffer from the overflow, so it can corrupt the heap by 
writing user data (see 3. and 5.).

This bug is present in Python 2.7.11.

See the result of running my attached POC script:
```
(gdb) r vuln.py
Starting program: /vagrant/Python-2.7.11/python.exe vuln.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
python.exe: malloc.c:2372: sysmalloc: Assertion `(old_top == (((mbinptr) 
(((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct 
malloc_chunk, fd && old_size == 0) || ((unsigned long) (old_size) >= 
(unsigned long)__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 
*(sizeof(size_t))) - 1)) & ~((2 *(sizeof(size_t))) - 1))) && ((old_top)->size & 
0x1) && ((unsigned long) old_end & pagemask) == 0)' failed.

Program received signal SIGABRT, Aborted.
0xb7fdd428 in __kernel_vsyscall ()
(gdb) bt
#0  0xb7fdd428 in __kernel_vsyscall ()
#1  0xb7de6607 in __GI_raise (sig=sig@entry=6) at 
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#2  0xb7de9a33 in __GI_abort () at abort.c:89
#3  0xb7e2a9dd in __malloc_assert (
assertion=assertion@entry=0xb7f1e3c0 "(old_top == (((mbinptr) (((char *) 
&((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd 
&& old_size == 0) || ((unsigned long) (old_size) >= (unsigned 
long)__builtin_offs"...,
file=file@entry=0xb7f19954 "malloc.c", line=line@entry=2372,
function=function@entry=0xb7f19ce5 <__func__.10915> "sysmalloc") at 
malloc.c:293
#4  0xb7e2d5eb in sysmalloc (av=0xb7f62420 , nb=16) at malloc.c:2369
#5  _int_malloc (av=av@entry=0xb7f62420 , bytes=bytes@entry=1) at 
malloc.c:3800
#6  0xb7e2e708 in __GI___libc_malloc (bytes=1) at malloc.c:2891
#7  0xb7b006b2 in _db_associateCallback (db=0x82a7dd0, priKey=0xb228, 
priData=0xb034, secKey=0x8291a80)
at /vagrant/Python-2.7.11/Modules/_bsddb.c:1531
...
```
We can see that the `malloc` call on the line marked (4.) fails due to 
corrupted heap structures.
Also, running the script outside of GDB leads to a different message because of 
differences in heap layout:
```
vagrant@vagrant-ubuntu-trusty-32:/vagrant/Python-2.7.11$ ./python.exe vuln.py
*** Error in `python': corrupted double-linked list: 0x099e9858 ***
Aborted (core dumped)
```

This vulnerability can be fixed by checking for the overflow before the call to 
malloc. Also, note that the PyBytes_Check check does not exit the function, but 
PyBytesAsStringAndSize is called immediately afterwards. I would recommend 
breaking or continuing if that check fails, although I do think 
PyBytesAsStringAndSize performs this check as well.

--
components: Library (Lib)
files: bsddbpoc.py
messages: 256974
nosy: Ned Williamson
priority: normal
severity: normal
status: open
title: Integer overflow in _bsddb leads to heap corruption
type: crash
versions: Python 2.7
Added file: http://bugs.python.org/file41408/bsddbpoc.py

___
Python tracker 

[issue25945] Type confusion in partial_setstate and partial_call leads to memory corruption

2015-12-24 Thread Ned Williamson

New submission from Ned Williamson:

static PyObject *
partial_setstate(partialobject *pto, PyObject *state)
{
PyObject *fn, *fnargs, *kw, *dict;
if (!PyArg_ParseTuple(state, "",
  , , , ))
return NULL;
Py_XDECREF(pto->fn);
Py_XDECREF(pto->args);
Py_XDECREF(pto->kw);
Py_XDECREF(pto->dict);
pto->fn = fn;
pto->args = fnargs; //we control pto->args here

`partial_setstate` performs no checks on the objects
it is passed as an argument.

static PyObject *
partial_call(partialobject *pto, PyObject *args, PyObject *kw)
{
PyObject *ret;
PyObject *argappl = NULL, *kwappl = NULL;

assert (PyCallable_Check(pto->fn));
assert (PyTuple_Check(pto->args)); //assume pto->args is a tuple
   //assertion not present in release build
assert (pto->kw == Py_None  ||  PyDict_Check(pto->kw));

if (PyTuple_GET_SIZE(pto->args) == 0) {
argappl = args;
Py_INCREF(args);
} else if (PyTuple_GET_SIZE(args) == 0) {
argappl = pto->args; //partial function called with no arguments
Py_INCREF(pto->args);
} else {
argappl = PySequence_Concat(pto->args, args);
if (argappl == NULL)
return NULL;
}

if (pto->kw == Py_None) {
kwappl = kw;
Py_XINCREF(kw);
} else {
kwappl = PyDict_Copy(pto->kw);
if (kwappl == NULL) {
Py_DECREF(argappl);
return NULL;
}
if (kw != NULL) {
if (PyDict_Merge(kwappl, kw, 1) != 0) {
Py_DECREF(argappl);
Py_DECREF(kwappl);
return NULL;
}
}
}
ret = PyObject_Call(pto->fn, argappl, kwappl); //pto->fn called with 
non-tuple argappl

We can see that in the provided POC there is an increment on a user-controlled 
address (in this case, the literal refcount of a given "argument" is 
interpreted as a pointer), as `_PyEval_EvalCodeWithName` does not validate the 
type of `PyObject **args` either (I assume this is a fair assumption for 
`_PyEval_EvalCodeWithName`, and the bug simply lies in the unsafe partial code.

vagrant@vagrant-ubuntu-wily-64:/vagrant/Python-3.5.1$ gdb -q ./python.exe
...
(gdb) r partialpoc2.py
Starting program: /vagrant/Python-3.5.1/python.exe partialpoc2.py
...
Program received signal SIGSEGV, Segmentation fault.
_PyEval_EvalCodeWithName (_co=0x77045ae0, globals=, 
locals=locals@entry=0x0, args=args@entry=0x76fbc520, argcount=1280, 
kws=kws@entry=0x0, kwcount=0, defs=0x0, defcount=0,
kwdefs=0x0, closure=0x0, name=0x0, qualname=0x0) at Python/ceval.c:3793
3793Py_INCREF(x);
(gdb) i r
rax0x9b4b68 10177384
rbx0x76fbc520   140737337083168
rcx0x1  1
rdx0x2  2
rsi0x5001280
rdi0x0  0
rbp0x0  0x0
rsp0x7fffdb30   0x7fffdb30
r8 0x5001280
r9 0x0  0
r100x774a6c58   140737342237784
r110x9b4b40 10177344
r120x0  0
r130x0  0
r140x76fb91e0   140737337070048
r150x77e1a048   140737352147016
rip0x4fc771 0x4fc771 <_PyEval_EvalCodeWithName+961>
eflags 0x10202  [ IF RF ]
cs 0x33 51
ss 0x2b 43
ds 0x0  0
es 0x0  0
fs 0x0  0
gs 0x0  0
(gdb) x/3i $pc
=> 0x4fc771 <_PyEval_EvalCodeWithName+961>: addq   $0x1,(%rsi)
   0x4fc775 <_PyEval_EvalCodeWithName+965>: cmp%edx,%r8d
   0x4fc778 <_PyEval_EvalCodeWithName+968>: mov%rsi,0x18(%rax,%rcx,8)

--
files: partialpoc2.py
messages: 256976
nosy: Ned Williamson
priority: normal
severity: normal
status: open
title: Type confusion in partial_setstate and partial_call leads to memory 
corruption
type: crash
versions: Python 3.5, Python 3.6
Added file: http://bugs.python.org/file41410/partialpoc2.py

___
Python tracker 

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



[issue25945] Type confusion in partial_setstate and partial_call leads to memory corruption

2015-12-24 Thread Ned Williamson

Changes by Ned Williamson :


--
components: +Library (Lib)

___
Python tracker 

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



Re: Idiom for this case?

2015-12-24 Thread Ben Finney
KP  writes:

> Given:
>
> cfg =  {'c': ('3840', '1024'),
>'p1': {'gpio': '1', 'id': '4', 'coord': ('0', '0', '1280', '1024')}, 
>'p2': {'gpio': '2', 'id': '5', 'coord': ('1280', '0', '2560', '1024')},
>'p3': {'gpio': '3', 'id': '6', 'coord': ('2560', '0', '3840', '1024')}}
>
> for config in cfg:
> if config != 'canvas':
> print config

Given the above data, none of the keys equal 'canvas', so the comparison
is redundant if that's the data set.

The chosen names are also confusing. It implies that each item of ‘cfg’
is a ‘config’. Can you choose names that better communicate the
semantics of that data structure?

> Is there an idiom that combines the 'for...' & the 'if..' lines into one?

This is an opportunity to learn generator expressions::

for item in (x for x in cfg if x != canvas):
print item



You will learn about these by working through the Python tutorial, from
beginning to end . Don't skip
anything, and experiment with each example to understand it before
continuing.

-- 
 \  “Anyone who believes exponential growth can go on forever in a |
  `\finite world is either a madman or an economist.” —Kenneth |
_o__) Boulding |
Ben Finney

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


[issue25946] configure should pick /usr/bin/g++ automatically if present

2015-12-24 Thread Karl Richter

New submission from Karl Richter:

`./configure` both prints `checking for g++... no` and 

WARNING:

  By default, distutils will build C++ extension modules with "g++".
  If this is not intended, then set CXX on the configure command line.

if `/usr/bin/g++` is present and executable which doesn't seem to be 
constructive because it's quite common that one wants to use `/usr/bin/g++` as 
CXX compiler if available. In case incompatibilities exists with other C++ 
compilers there should a check and more detailed error message.

Furthermore the error message doesn't explain if a part of distutils won't be 
build because the message sounds like the C++ extension is built, but does it 
work without a C++ compiler?

Specifying `CXX` environment variable or `--with-cxx-main=/usr/bin/g++` 
`configure` option works fine.

experienced with 8a2e735 (on branch 2.7)

--
components: Build
messages: 256977
nosy: krichter
priority: normal
severity: normal
status: open
title: configure should pick /usr/bin/g++ automatically if present
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



[issue25939] _ssl.enum_certificates() fails with ERROR_ACCESS_DENIED if python.exe run with low integrity level

2015-12-24 Thread Chi Hsuan Yen

Chi Hsuan Yen added the comment:

PsExec.exe seems not redistributable. PAExec is an alternative but I've not 
tried it. [1] Another option is re-implementing a tiny program for lowering the 
integrity level based on example codes provided in [2], which I've not tried 
yet, either. The latter option seems better to me as I didn't find codes for 
lowering the integrity level in PAExec's source code. [3]

[1] https://www.poweradmin.com/paexec/
[2] https://msdn.microsoft.com/en-us/library/bb625960.aspx
[3] https://github.com/poweradminllc/PAExec

--

___
Python tracker 

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



Re: unable to open IDLE for Python3.50rc1 on windows10 64bit AMD

2015-12-24 Thread Nicky Mac
wow - a very comprehensive answer.
However it seems I have now got it correctly reinstalled  with the correct
environment and path (as below) So I'm back to my original problem:

C:\Users\Nick>python -m idlelib
** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **

On doing a repair or modify to install tcl/Tk again, the same result.

C:\Users\Nick>python -c "import sys; print(*sys.path, sep='\n')"
 gives
C:\Python\Python35\python35.zip
C:\Python\Python35\DLLs
C:\Python\Python35\lib
C:\Python\Python35
C:\Python\Python35\lib\site-packages
This looks OK,  Python35 directory contains Lib and tcl as it does on my
now working Win7 system, and Lib contains tkinter

C:\Users\Nick>path
PATH=C:\Python\Python35\Scripts\;C:\Python\Python35\;C:\ProgramData\Oracle\Java\javapath;C:\Program
Files\Broadcom\Broadcom 802.11 Network
Adapter;;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
Files (x86)\ATI Technologies\ATI.ACE\Core-Static;
-- 
https://mail.python.org/mailman/listinfo/python-list


Is there an idiom for this?

2015-12-24 Thread KP
Given: 

cfg =  {'c': ('3840', '1024'), 
   'p1': {'gpio': '1', 'id': '4', 'coord': ('0', '0', '1280', '1024')}, 
   'p2': {'gpio': '2', 'id': '5', 'coord': ('1280', '0', '2560', '1024')}, 
   'p3': {'gpio': '3', 'id': '6', 'coord': ('2560', '0', '3840', '1024')}} 

for config in cfg: 
if config != 'c': 
print config 

Is there an idiom that combines the 'for...' & the 'if..' lines into one? 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: need some basic help

2015-12-24 Thread Terry Reedy

On 12/24/2015 2:33 PM, Qurrat ul Ainy wrote:

what is snippet ??


Search 'snippet definition' on the web with your browser.
It comes from 'snip', so something 'snipped'.


--
Terry Jan Reedy

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


Re: unable to open IDLE for Python3.50rc1 on windows10 64bit AMD

2015-12-24 Thread eryk sun
On Thu, Dec 24, 2015 at 4:45 PM, Terry Reedy  wrote:
>
>> This file should not exist. Python 3 stores .pyc files in a
>> __pycache__ subdirectory. It won't even run "idlelib\__init__.pyc" if
>> "idlelib\__init__.py" exists, so your installation is incomplete and
>> damaged. I suggest that you uninstall Python 3.5 and then completely
>> remove "C:\Python\Python35" before reinstalling.
>
> 'python -m xyz', where xyz is a package name (directory on disk), runs
> xyx/__main__.py (or the xyz/__pycache__/__main__...34.py compiled version).

Running "-m idlelib" still imports idlelib, which executes
__init__.py(c).  For example, I modified __init__.py to print a
message:

C:\>py -3 -m idlelib
Here I am.

Specifically, runpy._run_module_as_main('idlelib', 1) calls
runpy._get_module_details, which recurs to get the details for
"idlelib.__main__". but first it executes __import__("idlelib") to
"avoid catching initialization errors". It returns the module spec and
the code object. Then _run_module_as_main calls runpy._run_code to
exec the code in the namespace of __main__.

That said, Python 3's import system should ignore a .pyc beside a .py
file, because it looks for .pyc files in the __pycache__ subdirectory.
It only executes "idlelib\__init__.pyc" if the corresponding .py file
is missing. That's why I said Nicky's installation was both incomplete
(missing "__init__.py") and damaged (somehow containing a Python 2.7
"__init__.pyc"), so I suggested a completely fresh install. Apparently
that didn't help, so I presume for some reason it's not actually
installing the _tkinter extension module and its dependencies.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25944] Type confusion in partial_setstate and partial_repr leads to control flow hijack

2015-12-24 Thread Ned Williamson

New submission from Ned Williamson:

static PyObject *
partial_setstate(partialobject *pto, PyObject *state)
{
PyObject *fn, *fnargs, *kw, *dict;
if (!PyArg_ParseTuple(state, "",
  , , , ))
return NULL;
Py_XDECREF(pto->fn);
Py_XDECREF(pto->args);
Py_XDECREF(pto->kw);
Py_XDECREF(pto->dict);
pto->fn = fn;
pto->args = fnargs; //we control pto->args here

`partial_setstate` performs no checks on the objects
it is passed as an argument.

static PyObject *
partial_repr(partialobject *pto)
{
PyObject *result;
PyObject *arglist;
PyObject *tmp;
Py_ssize_t i, n;
arglist = PyUnicode_FromString("");
if (arglist == NULL) {
return NULL;
}
/* Pack positional arguments */
assert (PyTuple_Check(pto->args)); //not compiled in release build
n = PyTuple_GET_SIZE(pto->args);
for (i = 0; i < n; i++) {
tmp = PyUnicode_FromFormat("%U, %R", arglist,
   PyTuple_GET_ITEM(pto->args, i));

In partial_repr, `pto->args` is assumed to be a tuple and
unsafe functions `PyTuple_GET_SIZE` and `PyTuple_GET_ITEM`
are called on `pto->args`. This bug is particularly bad
because `PyUnicode_FromFormat` will call the object's repr
function. In this case, the attacker gains complete control
over the program counter.

vagrant@vagrant-ubuntu-wily-64:/vagrant/Python-3.5.1$ gdb -q ./python.exe
...
(gdb) r partialpoc.py
Starting program: /vagrant/Python-3.5.1/python.exe partialpoc.py
...
Program received signal SIGSEGV, Segmentation fault.
0x004851f6 in PyObject_Repr (v=0x972c90) at Objects/object.c:482
482 res = (*v->ob_type->tp_repr)(v);
(gdb) i r
rax0x4141414141414141   4702111234474983745
rbx0x972c90 9907344
rcx0x52 82
rdx0x77026718   140737337517848
rsi0x0  0
rdi0x972c90 9907344
rbp0x6667   0x6667
rsp0x7fffdb60   0x7fffdb60
r8 0x0  0
r9 0x6049a8 6310312
r100x   -1
r110x   -1
r120x7fff   9223372036854775807
r130x7fffdbe0   140737488346080
r140x6049a7 6310311
r150x0  0
rip0x4851f6 0x4851f6 
eflags 0x10206  [ PF IF RF ]
cs 0x33 51
ss 0x2b 43
ds 0x0  0
es 0x0  0
fs 0x0  0
gs 0x0  0
(gdb) x/3i $pc
=> 0x4851f6 : callq  *%rax
   0x4851f8 : test   %rax,%rax
   0x4851fb : mov%rax,%rbx

Please see the attached POC.

--
components: Library (Lib)
files: partialpoc.py
messages: 256975
nosy: Ned Williamson
priority: normal
severity: normal
status: open
title: Type confusion in partial_setstate and partial_repr leads to control 
flow hijack
type: crash
versions: Python 3.5, Python 3.6
Added file: http://bugs.python.org/file41409/partialpoc.py

___
Python tracker 

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



Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-24 Thread Erik

On 24/12/15 19:36, malitic...@gmail.com wrote:

you are right chris
it is a homework, but we are to figure out the solution first , all we need is 
some guidance please and not to be spoon fed like many thought


From your response, it seems that this is a homework question that a 
group of you are working on. That might explain some of the confusion 
(both from your side, posting similar questions and slightly confusing 
replies) and from the list side (asking why different email addresses 
were being used - it all seemed a bit suspicious) ...


I would recommend that one of you acts as a spokesperson for the group.



However, this latest response is much better. You included your code, 
and it looks like it would compile (I haven't run it myself, but you've 
included reasonable results too).


Your problem looks like it's related to how the unit test harness 
reports its errors and I guess it's a bit unfair for you to completely 
have to understand how that works if you're just learning. However, the 
wording of the assignment _does_ give a clue as to the problem.


The error seems to be coming from the test for the "withdraw" method 
with a value greater that what should be the current balance:


> [{"message": "Failure in line 23, in test_invalid_operation\n 
self.assertEqual(self.my_account.withdraw(1000), \"invalid 
transaction\", msg='Invalid transaction')\nAssertionError: Invalid 
transaction\n"}]}], "specs": {"count": 5, "pendingCount": 0, "time": 
"0.80"}}


Your assignment said:


Create a method called `withdraw` that takes in cash withdrawal amount and updates the 
balance accordingly. if amount is greater than balance return `"invalid 
transaction"`


Your method is:


 def withdraw(self, amount):
 if self.balance>= amount:
 self.balance  -=  amount
 else:
   print('invalid transaction')


Can you spot the difference between what the assignment is asking for 
and what the method is doing? Look at both paths carefully (when called 
with a valid amount and when called with an amount that is too large). 
Pay careful attention to the words the assignment uses.



a1 = BankAccount (90)
a1.deposit(90)
a1.withdraw(40)
a1.withdraw(1000)
class MinimumBalanceAccount(BankAccount):
 def __init__(self):
 BankAccount.__init__(self)

[snip]

i believe the last three lines of my code answered your question.


When the assignment requested you create a subclass, it probably 
expected a subclass that would run. Have you tried creating an instance 
of your subclass? Try it - you might see another problem that needs fixing.


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


Idiom for this case?

2015-12-24 Thread KP
Given:

cfg =  {'c': ('3840', '1024'),
   'p1': {'gpio': '1', 'id': '4', 'coord': ('0', '0', '1280', '1024')}, 
   'p2': {'gpio': '2', 'id': '5', 'coord': ('1280', '0', '2560', '1024')},
   'p3': {'gpio': '3', 'id': '6', 'coord': ('2560', '0', '3840', '1024')}}

for config in cfg:
if config != 'canvas':
print config

Is there an idiom that combines the 'for...' & the 'if..' lines into one?

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


[issue25941] Add 'How to Review a Patch' section to devguide

2015-12-24 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
nosy: +terry.reedy

___
Python tracker 

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



Re: unable to open IDLE for Python3.50rc1 on windows10 64bit AMD

2015-12-24 Thread eryk sun
On Thu, Dec 24, 2015 at 4:33 PM, Terry Reedy  wrote:
>> somehow the new py3.5 has been added to the end, not the beginning.
>> guess this path is what you meant by "my profile".
>
> Bizarre.  I just installed 3.5.1 on top of 3.5.1rc1, on Win10 with the 64bit
> .exe installer, and the 3.5 dirs are at the front, where I expect them.  Are
> you using a different version of installer? (The web version?)

If you install just for the current user, the installer modifies only
the user's "HKCU\Environment" key in the registry. When you log on, or
when Explorer reloads its environment, the value of PATH is formed by
concatenating the user value to the end of the system value.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25939] _ssl.enum_certificates() fails with ERROR_ACCESS_DENIED if python.exe run with low integrity level

2015-12-24 Thread Steve Dower

Steve Dower added the comment:

Looks good to me.

Is it worth dropping psexec.exe into the test suite so we can add a test for 
this (or maybe into tools so we can run it from a build without redistributing 
the exe)? It'll probably be helpful elsewhere too (symlink tests, for example).

--

___
Python tracker 

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



[issue25939] _ssl.enum_certificates() fails with ERROR_ACCESS_DENIED if python.exe run with low integrity level

2015-12-24 Thread Eryk Sun

Eryk Sun added the comment:

psexec.exe can be run from the the live server.

>>> subprocess.call(r'\\live.sysinternals.com\tools\psexec.exe -s whoami')

PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com


nt authority\system
whoami exited on THISPC with error code 0.
0

But the executable could also be cached on the test system.

--
nosy: +eryksun

___
Python tracker 

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



Re: Python and multiple user access via super cool fancy website

2015-12-24 Thread Jason Friedman
> I am not sure if this is the correct venue for my question, but I'd like to
> submit my question just in case.  I am not a programmer but I do have an
> incredible interest in it, so please excuse my lack of understanding if my
> question isn't very thorough.
>
> As an example, a website backend is developed using Python.  Users can
> submit their input through the website and PHP (or some other language)
> transfers the user input from the website fields to a database such as
> MySQL.  There is a main script called main_script.py which extracts the
> user data from MySQL, processes it, stores output in MySQL and sends output
> to the user (via webpage and email).
>
> About main_script.py
> # main_script.py extracts user input from MySQL, processes it, stores
> output in MySQL and send output to user (via webpage and email).
> # Inputs: User personal information such as age, dob, nationality, hobbies,
> and 20 or 30 other fields
> # Output: main_script.py is going to do something with it such as access
> the database and some shelve files or other py scripts. I have no clue what
> it's going to do, but my point is that the processing of the input to
> output will take longer than simply a print('Hello, %r!' %user_name).
>
> My question:  I am curious to know how Python handles something like this.
> Let's say that there are 10, 20, 50, or even 1000 users accessing the
> website.  They all put in their 20 to 30 pieces of input and are waiting on
> some fancy magic output.  How exactly does that work?  Can multiple users
> access the same script?  Does the Python programmer need to code in a
> manner that supports this?  Are requests to the script handled serially or
> in parallel?

I have a hunch that you do not want to write the program, nor do you
want to see exactly how a programmer would write it?

The question is more like asking a heart surgeon how she performs
heart surgery:  you don't plan to do it yourself, but you want a
general idea of how it is done?  How do you keep the patient from
bleeding to death?  Does the heart stop while performing the surgery,
and if yes, how does the patient stay alive?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there an idiom for this?

2015-12-24 Thread KP
Thanks Paul, you just pointed out one of my blonder moments: 

I actually want all nested dicts one by one, but not the one with the 'c' key...



On Thursday, 24 December 2015 14:15:45 UTC-8, Paul Rubin  wrote:
> KP writes:
> > for config in cfg: 
> > if config != 'c': 
> > print config 
> >
> > Is there an idiom that combines the 'for...' & the 'if..' lines into one? 
> 
> Maybe you actually want
> 
>   print [config for config in cfg if config != 'c']
> 
> That prints all the relevant keys as a list, rather than one per line.

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


Re: unable to open IDLE for Python3.50rc1 on windows10 64bit AMD

2015-12-24 Thread Terry Reedy

On 12/24/2015 8:59 AM, Nicky Mac wrote:

Dear python Team
I think I've been wasting your time:

C:\Users\Nick>path
PATH=C:\Python27\;C:\Python27\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\Program
Files\Broadcom\Broadcom 802.11 Network
Adapter;;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
Files (x86)\ATI
Technologies\ATI.ACE\Core-Static;C:\Python\Python35\Scripts\;C:\Python\Python35\

somehow the new py3.5 has been added to the end, not the beginning.
guess this path is what you meant by "my profile".


Bizarre.  I just installed 3.5.1 on top of 3.5.1rc1, on Win10 with the 
64bit .exe installer, and the 3.5 dirs are at the front, where I expect 
them.  Are you using a different version of installer? (The web version?)


--
Terry Jan Reedy

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


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-24 Thread Tim Chase
On 2015-12-24 11:36, malitic...@gmail.com wrote:
> it is a homework, but we are to figure out the solution first , all
> we need is some guidance please and not to be spoon fed like many
> thought 

Ah, with the intended interface as given by the tests, and the code
you've already put together, you'll find comp.lang.python is a much
friendlier place.


>   def test_invalid_operation(self):
> self.assertEqual(self.my_account.withdraw(1000), "invalid
> transaction", msg='Invalid transaction') 

The test above is failing because your withdraw() method doesn't
return "invalid transaction" but rather prints it:

> def withdraw(self, amount):
> if self.balance>= amount:
> self.balance  -=  amount
> else:
>   print('invalid transaction')

as gleaned from this error message:

> [{"message": "Failure in line 23, in test_invalid_operation\n
> self.assertEqual(self.my_account.withdraw(1000), \"invalid
> transaction\", msg='Invalid transaction')\nAssertionError: Invalid
> transaction\n"}]}], "specs": {"count": 5, "pendingCount": 0,
> "time": "0.80"}}

The test says "I expected that calling the function would return
"invalid transaction" but it didn't" (a better test-runner would
also have let you know that it had returned None)

Though frankly, I'd consider that a bad test, since it's an
exceptional condition, so it should be checking that a custom
InvalidTransactionException was raised.  But sometimes you have to
work with what you've got.

-tkc



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


Re: Python and multiple user access via super cool fancy website

2015-12-24 Thread Tim Chase
On 2015-12-24 14:39, Aaron Christensen wrote:
> I am not sure if this is the correct venue for my question, but I'd
> like to submit my question just in case.  I am not a programmer but
> I do have an incredible interest in it, so please excuse my lack of
> understanding if my question isn't very thorough.

First, to do web development, you do need to be a programmer. Well,
at least for anything of any complexity/novelty.  But come on in,
it's a fun place to be!

> As an example, a website backend is developed using Python.  Users
> can submit their input through the website and PHP (or some other
> language) transfers the user input from the website fields to a
> database such as MySQL.  There is a main script called
> main_script.py which extracts the user data from MySQL, processes
> it, stores output in MySQL and sends output to the user (via
> webpage and email).

A website backend can either static (just a pile of files that get
served up by your web-server such as Apache or nginx, fast, but
usually read-only such as a blog) or dynamic[1].  With a dynamic
website, you have some language running on the server.  Germane to
this list, that's Python for many of us. But could be PHP, Perl,
Ruby, C#, Java, Erlang, bash, or even sed/awk or Postscript.  Pretty
much any programming language can do the trick here.

The web application then parses input from the *request*.  This is
usually made by the web-browser, but can also be made by other
applications.  The application then processes those inputs and
determines the correct output.  This might involve consulting a
database such as PostgreSQL or MySQL to save data or gather the
requested data, or it might farm that out to some other service.  It
might check that you're logged in.  It might be purely read-only but
pull information from a database or random set of files.  The main
thing to understand is that a request comes in, gets processed, and
a response goes back.

[1] or a hybrid of a dynamic site where certain assets such as
images, CSS, and JavaScript are static and served outside the web
application.

-

> # main_script.py extracts user input from MySQL, processes it,
> stores output in MySQL and send output to user (via webpage and
> email). # Inputs: User personal information such as age, dob,
> nationality, hobbies, and 20 or 30 other fields

So here it sounds like you think that the input comes from *MySQL*
but it will actually come from the request.

Now you can have some other (non-web) process access the same database
that the web-server uses, so your inputs *can* be the database, but
that doesn't sound like what you're intending to describe. 

> My question:  I am curious to know how Python handles something
> like this. Let's say that there are 10, 20, 50, or even 1000 users
> accessing the website.  They all put in their 20 to 30 pieces of
> input and are waiting on some fancy magic output.  How exactly does
> that work?  Can multiple users access the same script?  Does the
> Python programmer need to code in a manner that supports this?  Are
> requests to the script handled serially or in parallel?

As Chris W mentions, there are lots of high-profile sites that handle
hundreds of thousands of visitors.  Usually they do this by splitting
the load across multiple servers using a load-balancer, and with
careful architecture that can accommodate characteristics of that
load.  Yes, multiple users can make use of the same script (it's
usually run by a web-server which spawns multiple copies and farms
out each request to a different sub-process).  And yes, the
programmer has to code to support this non-trivial aspect.  It's as
parallel as your architecture allows (you *can* make a
single-threaded server that will only serve one request at a time
which can be useful in development or if you want to just share with
one other user).

-tkc



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


[issue25945] Type confusion in partial_setstate and partial_call leads to memory corruption

2015-12-24 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
components: +Extension Modules -Library (Lib)
nosy: +ncoghlan, rhettinger, serhiy.storchaka
stage:  -> needs patch
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



[issue25941] Add 'How to Review a Patch' section to devguide

2015-12-24 Thread Camilla Montonen

New submission from Camilla Montonen:

This list is based on helpful tips and discussions received on the 
core-mentorship list and aims to help new beginners review patches in the bug 
tracker. The submitted patch is still in progress (the layout is a bit wonky 
and some details are still missing).

--
components: Devguide
files: patchreview.patch
keywords: patch
messages: 256970
nosy: Winterflower, ezio.melotti, willingc
priority: normal
severity: normal
status: open
title: Add 'How to Review a Patch' section to devguide
Added file: http://bugs.python.org/file41406/patchreview.patch

___
Python tracker 

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



Re: unable to open IDLE for Python3.50rc1 on windows10 64bit AMD

2015-12-24 Thread eryk sun
On Thu, Dec 24, 2015 at 3:29 PM, Nicky Mac  wrote:
>
> C:\Users\Nick>python -m idlelib
> ** IDLE can't import Tkinter.
> Your Python may not be configured for Tk. **

In the 3.5 installation directory, ensure that tkinter is installed in
Lib/tkinter. There should be an "__init__.py" and several other files
such as "filedialog.py". Also ensure that the DLLs  directory has the
extension module "_tkinter.pyd" and dependent DLLs "tcl86t.dll" and
"tk86t.dll".
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Idiom for this case?

2015-12-24 Thread Terry Reedy

On 12/24/2015 5:04 PM, KP wrote:

Given:

cfg =  {'c': ('3840', '1024'),
'p1': {'gpio': '1', 'id': '4', 'coord': ('0', '0', '1280', '1024')},
'p2': {'gpio': '2', 'id': '5', 'coord': ('1280', '0', '2560', '1024')},
'p3': {'gpio': '3', 'id': '6', 'coord': ('2560', '0', '3840', '1024')}}

for config in cfg:
 if config != 'canvas':
 print config

Is there an idiom that combines the 'for...' & the 'if..' lines into one?


No.

--
Terry Jan Reedy

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


[issue25939] _ssl.enum_certificates() fails with ERROR_ACCESS_DENIED if python.exe run with low integrity level

2015-12-24 Thread Chi Hsuan Yen

Chi Hsuan Yen added the comment:

OK I've just succeeded in creating a low integrity level process with my own 
codes. Now the problem is: how can I integrate this tool into the test system? 
Seems the integrity level is per-process, while all tests are run in the same 
process.

--
Added file: http://bugs.python.org/file41411/lower_integrity_level.c

___
Python tracker 

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



Re: unable to open IDLE for Python3.50rc1 on windows10 64bit AMD

2015-12-24 Thread Mark Lawrence

On 24/12/2015 14:52, Nicky Mac wrote:

what a horrible environment windows is to support anything!
(I was a UNIX professional).
seems the user profile PATH is a registry entry, and was not updated when I
deinstalled Python2.7
still haven't  figured out how to change it - I will NOT attempy a regedit.


I don't have a problem, but then I don't top post on lists that greatly 
prefer bottom posting or interspersed answers.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-24 Thread Gene Heskett
On Thursday 24 December 2015 12:30:08 Grant Edwards wrote:

> On 2015-12-24, D'Arcy J.M. Cain  wrote:
> > It reminds me of when one day people started claiming to be
> > "building" computers and they didn't even own a soldering iron.
>
> And don't get me started on those people who use those "integrated
> circuits" instead of transistors, relays, and tubes...
>
> --
> Grant

Yeah, I'm sorta old fashioned that way. I can remember when electrolytic 
capacitors were actually wet. And tubes had numbers like an 80, or a 46, 
or a 2A3 for "high" powered audio even. Power transformers that made 700 
volts, center tapped of course, and because of the poor iron, weighed 25 
lbs.  With todays modern megnetic steels, the heating losses are 10% of 
that one, and it weights 6 lbs.  We've come a long way in my 81 years...

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-24 Thread D'Arcy J.M. Cain
On Thu, 24 Dec 2015 17:30:08 + (UTC)
Grant Edwards  wrote:
> And don't get me started on those people who use those "integrated
> circuits" instead of transistors, relays, and tubes...

Mmmm.  Tubes.  Still use them in my guitar amp.  Transistors just
aren't the same thing.

-- 
D'Arcy J.M. Cain
Vybe Networks Inc.
http://www.VybeNetworks.com/
IM:da...@vex.net VoIP: sip:da...@vybenetworks.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: need some basic help

2015-12-24 Thread Qurrat ul Ainy
what is snippet ??



On Thursday, December 24, 2015 at 5:25:18 AM UTC+1, Benjamin Kulas wrote:
> On Wednesday, December 23, 2015 at 7:53:43 PM UTC-6, Qurrat ul Ainy wrote:
> > Hello,
> > 
> > Can someone please explain this code below. I am new at Python .
> > Thanks 
> > 
> > 
> > def receive_messages(self, msgs, time):
> >   for msg in msgs:
> >  msg.set_recv_time(time)
> >   self.msgs_received.extend(msgs)
> 
> What exactly are you confused about? This looks like it is part of a class; 
> can you post the entire class definition? Also, what is the purpose of the 
> program that contains this snippet?

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


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-24 Thread malitician
On Thursday, December 24, 2015 at 3:39:34 PM UTC+1, Chris Angelico wrote:
> On Fri, Dec 25, 2015 at 1:17 AM,   wrote:
> > i am getting to believe that no one can provide a solution to this 
> > challenge, every-one here is just beating around the bush
> 
> It's not a question of 'can' but 'will'. We will not provide the
> answer to your homework question. This has already been explained to
> you.
> 
> ChrisA




you are right chris
it is a homework, but we are to figure out the solution first , all we need is 
some guidance please and not to be spoon fed like many thought 


in case anybody missed the question here is it 





>Create a class called BankAccount

>Create a constructor that takes in an integer and assigns this to a `balance` 
>property.

>Create a method called `deposit` that takes in cash deposit amount and updates 
>the balance accordingly.

>Create a method called `withdraw` that takes in cash withdrawal amount and 
>updates the balance accordingly. if amount is greater than balance return 
>`"invalid transaction"`

>Create a subclass MinimumBalanceAccount of the BankAccount class



and there is a unittest that evaluate our code to check if we got it right ( i 
believe) and here  it is below








import unittest
class AccountBalanceTestCases(unittest.TestCase):
  def setUp(self):
self.my_account = BankAccount(90)

  def test_balance(self):
self.assertEqual(self.my_account.balance, 90, msg='Account Balance Invalid')

  def test_deposit(self):
self.my_account.deposit(90)
self.assertEqual(self.my_account.balance, 180, msg='Deposit method 
inaccurate')

  def test_withdraw(self):
self.my_account.withdraw(40)
self.assertEqual(self.my_account.balance, 50, msg='Withdraw method 
inaccurate')

  def test_invalid_operation(self):
self.assertEqual(self.my_account.withdraw(1000), "invalid transaction", 
msg='Invalid transaction')
  
  def test_sub_class(self):
self.assertTrue(issubclass(MinimumBalanceAccount, BankAccount), msg='No 
true subclass of BankAccount')




and i come up with this code which i believe i'm 80 percent correct




class BankAccount:
def __init__(self, initial_amount):
self.balance = initial_amount
def deposit(self, amount):
self.balance += amount
def withdraw(self, amount):
if self.balance>= amount:
self.balance  -=  amount
else:
  print('invalid transaction')

a1 = BankAccount (90)
a1.deposit(90)
a1.withdraw(40)
a1.withdraw(1000)
class MinimumBalanceAccount(BankAccount):
def __init__(self):
BankAccount.__init__(self)






but i kept getting this error from the unittest





{"finished": true, "success": [{"fullName": "test_balance", "passedSpecNumber": 
1}, {"fullName": "test_deposit", "passedSpecNumber": 2}, {"fullName": 
"test_sub_class", "passedSpecNumber": 3}, {"fullName": "test_withdraw", 
"passedSpecNumber": 4}], "passed": false, "started": true, "failures": 
[{"failedSpecNumber": 1, "fullName": "test_invalid_operation", 
"failedExpectations": [{"message": "Failure in line 23, in 
test_invalid_operation\nself.assertEqual(self.my_account.withdraw(1000), 
\"invalid transaction\", msg='Invalid transaction')\nAssertionError: Invalid 
transaction\n"}]}], "specs": {"count": 5, "pendingCount": 0, "time": 
"0.80"}}
invalid transaction
invalid transaction





its like this part of the unittest explains my error  




[{"message": "Failure in line 23, in test_invalid_operation\n
self.assertEqual(self.my_account.withdraw(1000), \"invalid transaction\", 
msg='Invalid transaction')\nAssertionError: Invalid transaction\n"}]}], 
"specs": {"count": 5, "pendingCount": 0, "time": "0.80"}}



but i dont know what it means or where i have gone wrong in my code
and for that need help on Create a subclass MinimumBalanceAccount of the 
BankAccount class

i believe the last three lines of my code answered your question.
i believe someone can help me with my problem.
Thanks in advance
-- 
https://mail.python.org/mailman/listinfo/python-list


Python and multiple user access via super cool fancy website

2015-12-24 Thread Aaron Christensen
Hi all,

I am not sure if this is the correct venue for my question, but I'd like to
submit my question just in case.  I am not a programmer but I do have an
incredible interest in it, so please excuse my lack of understanding if my
question isn't very thorough.

As an example, a website backend is developed using Python.  Users can
submit their input through the website and PHP (or some other language)
transfers the user input from the website fields to a database such as
MySQL.  There is a main script called main_script.py which extracts the
user data from MySQL, processes it, stores output in MySQL and sends output
to the user (via webpage and email).

About main_script.py
# main_script.py extracts user input from MySQL, processes it, stores
output in MySQL and send output to user (via webpage and email).
# Inputs: User personal information such as age, dob, nationality, hobbies,
and 20 or 30 other fields
# Output: main_script.py is going to do something with it such as access
the database and some shelve files or other py scripts. I have no clue what
it's going to do, but my point is that the processing of the input to
output will take longer than simply a print('Hello, %r!' %user_name).

My question:  I am curious to know how Python handles something like this.
Let's say that there are 10, 20, 50, or even 1000 users accessing the
website.  They all put in their 20 to 30 pieces of input and are waiting on
some fancy magic output.  How exactly does that work?  Can multiple users
access the same script?  Does the Python programmer need to code in a
manner that supports this?  Are requests to the script handled serially or
in parallel?

I've tried some searches, but not getting much except for "appending to the
same file", etc.

I hope my question is a good question.  Thank you for your time!
Aaron
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: need some basic help

2015-12-24 Thread Qurrat ul Ainy
On Thursday, December 24, 2015 at 8:33:59 PM UTC+1, Qurrat ul Ainy wrote:
> what is snippet ??
> 
> 
> 
> On Thursday, December 24, 2015 at 5:25:18 AM UTC+1, Benjamin Kulas wrote:
> > On Wednesday, December 23, 2015 at 7:53:43 PM UTC-6, Qurrat ul Ainy wrote:
> > > Hello,
> > > 
> > > Can someone please explain this code below. I am new at Python .
> > > Thanks 
> > > 
> > > 
> > > def receive_messages(self, msgs, time):
> > >   for msg in msgs:
> > >  msg.set_recv_time(time)
> > >   self.msgs_received.extend(msgs)
> > 
> > What exactly are you confused about? This looks like it is part of a class; 
> > can you post the entire class definition? Also, what is the purpose of the 
> > program that contains this snippet?

Thank you steven foe the detail explanation i got it now. 
and thank you Andrew for recommendation I really need that 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and multiple user access via super cool fancy website

2015-12-24 Thread Chris Warrick
On 24 December 2015 at 20:39, Aaron Christensen
 wrote:
> Hi all,
>
> I am not sure if this is the correct venue for my question, but I'd like to
> submit my question just in case.  I am not a programmer but I do have an
> incredible interest in it, so please excuse my lack of understanding if my
> question isn't very thorough.
>
> As an example, a website backend is developed using Python.  Users can
> submit their input through the website and PHP (or some other language)

Cut out the middle man! Write your web app in Python, which is much
saner and more modern than PHP ever will be. Write it in Django, or
Flask, or Pyramid, or [insert favorite web framework here].

> transfers the user input from the website fields to a database such as
> MySQL.  There is a main script called main_script.py which extracts the
> user data from MySQL, processes it, stores output in MySQL and sends output
> to the user (via webpage and email).
>
> About main_script.py
> # main_script.py extracts user input from MySQL, processes it, stores
> output in MySQL and send output to user (via webpage and email).
> # Inputs: User personal information such as age, dob, nationality, hobbies,
> and 20 or 30 other fields
> # Output: main_script.py is going to do something with it such as access
> the database and some shelve files or other py scripts. I have no clue what
> it's going to do, but my point is that the processing of the input to
> output will take longer than simply a print('Hello, %r!' %user_name).

Well then, figure it out first.You shouldn’t be using shelve, it’s
really unsafe and error-prone — and you already have a perfectly
serviceable database! (PS. PostgreSQL is better)

> My question:  I am curious to know how Python handles something like this.
> Let's say that there are 10, 20, 50, or even 1000 users accessing the
> website.  They all put in their 20 to 30 pieces of input and are waiting on
> some fancy magic output.  How exactly does that work?  Can multiple users
> access the same script?  Does the Python programmer need to code in a
> manner that supports this?  Are requests to the script handled serially or
> in parallel?

We don’t know how you will structure your application.
If you do the “fancy magic” in your web app, which you should if it
won’t take more than, say, 5 seconds, this will be handled by your
WSGI server (eg. uwsgi), which typically can spawn threads and
processes for your web application. Otherwise, you might need to use
an async framework or a task queue with multiple workers.
It would be better to have some idea of the desired output, though.

There are many Python-based web services out there, eg. YouTube,
Instagram or DISQUS. And they work well under constant load.
-- 
Chris Warrick 
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25939] _ssl.enum_certificates() fails with ERROR_ACCESS_DENIED if python.exe run with low integrity level

2015-12-24 Thread Chi Hsuan Yen

New submission from Chi Hsuan Yen:

Originally reported at https://github.com/rg3/youtube-dl/issues/7951

Steps to reproduce:
1. Build 99665:dcf9e9ae5393 with Visual Studio 2015
2. Download and extract PsTools [1]
3. PsExec.exe -l python.exe
4. In Python, run:

import _ssl
_ssl.enum_certificates("CA")
_ssl.enum_crls("CA")

Results:
Python 3.6.0a0 (default, Dec 25 2015, 02:42:42) [MSC v.1900 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import _ssl
>>> _ssl.enum_certificates("CA")
Traceback (most recent call last):
  File "", line 1, in 
PermissionError: [WinError 5] Access is denied
>>> _ssl.enum_crls("CA")
Traceback (most recent call last):
  File "", line 1, in 
PermissionError: [WinError 5] Access is denied
>>>

Windows Vista and above have a security mechanism called "Low Integrity Level". 
[2] With that, only some specific registry keys are writable. In the original 
_ssl.c, both enum_certificates() and enum_crls() calls CertOpenSystemStore(). 
At least on my system CertOpenSystemStore() tries to open 
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SystemCertificates\CA with read/write 
permissions. (Observed with Process Monitor [3]) The request fails in Low 
Integrity Level processes as it's not in the range of writable registry keys.

Here I propose a fix: open certificate stores with the read-only flag. There 
are some points I'm not sure in this patch:
1. CERT_STORE_PROV_SYSTEM_A: I guess strings are bytestrings in C level?
2. CERT_SYSTEM_STORE_LOCAL_MACHINE: In accounts of Administrators, 
CertOpenSystemStore() tries to open keys under HKLM only, while in restricted 
(standard) accounts, this function tries to open keys under HKCU with R/W 
permission and keys under HKLM read-only. I think open system global stores is 
OK here.
A different perspective: Wine developers always open keys under HKCU in 
CertOpenSystemStore()

Environment: Windows 7 SP1 (6.1.7601) x86, an account in Administrators group. 
Tested with python.exe Lib\test\test_ssl.py both in a normal shell and within 
`PsExec -l`

Ref: issue17134, where these codes appear the first time

[1] https://technet.microsoft.com/en-us/sysinternals/pstools.aspx
[2] https://msdn.microsoft.com/en-us/library/bb625960.aspx
[3] https://technet.microsoft.com/en-us/sysinternals/processmonitor.aspx
[4] https://github.com/wine-mirror/wine/blob/master/dlls/crypt32/store.c

--
components: Extension Modules, Windows
files: open-system-store-readonly.patch
keywords: patch
messages: 256968
nosy: Chi Hsuan Yen, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: _ssl.enum_certificates() fails with ERROR_ACCESS_DENIED if python.exe 
run with low integrity level
type: crash
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file41405/open-system-store-readonly.patch

___
Python tracker 

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



[issue25940] SSL tests failed due to expired svn.python.org SSL certificate

2015-12-24 Thread Chi Hsuan Yen

New submission from Chi Hsuan Yen:

The certificate of svn.python.org expires at Thu 24 Dec 2015 08:28:32 PM CST 
GMT, about 20 minutes ago. Please update its certificate or lots of tests in 
Lib\test\test_ssl.py fails with SSL: CERTIFICATE_VERIFY_FAILED.

--
components: Tests
messages: 256969
nosy: Chi Hsuan Yen
priority: normal
severity: normal
status: open
title: SSL tests failed due to expired svn.python.org SSL certificate
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, 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



Re: Bug in Python 3.5.1

2015-12-24 Thread Laurent Pointal
Hello,

nisthesec...@verizon.net wrote:

> Dear Sir,
>I downloaded and installed Python 3.5.1 in Windows 10.
>The pip command was not part of it.
>In the future, can you kindly include numpy, scipy, and pygame as part
>of the Python release?
>I am a teacher trying to teach Python to my students.
>To get a working version of Python going is extremely tedious.
>Kind Regards,
>Nick Srinivasan

IMHO There is no chance that all these packages be distributed with Python 
in the standard libs.

Near the third party distributions already signaled (Anaconda, but there is 
also Pythonxy and others), for students you can take a look a Pyzo, which 
integrate an IDE with some common scientific packages.

http://www.pyzo.org/

It include following packages:

http://www.pyzo.org/packages.html#packages

But, no pygame… (maybe it can be installed via conda as indicated on this 
page - you may test under common student OS).

A+
Laurent.

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


Re: unable to open IDLE for Python3.50rc1 on windows10 64bit AMD

2015-12-24 Thread Nicky Mac
what a horrible environment windows is to support anything!
(I was a UNIX professional).
seems the user profile PATH is a registry entry, and was not updated when I
deinstalled Python2.7
still haven't  figured out how to change it - I will NOT attempy a regedit.

season's greetings

On 24 December 2015 at 13:59, Nicky Mac  wrote:

> Dear python Team
> I think I've been wasting your time:
>
> C:\Users\Nick>path
> PATH=C:\Python27\;C:\Python27\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\Program
> Files\Broadcom\Broadcom 802.11 Network
> Adapter;;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
> Files (x86)\ATI
> Technologies\ATI.ACE\Core-Static;C:\Python\Python35\Scripts\;C:\Python\Python35\
>
> somehow the new py3.5 has been added to the end, not the beginning.
> guess this path is what you meant by "my profile".
> I'll set about fixing it.
> Meery christmas to you all
> Nick
>
> On 24 December 2015 at 11:06, Nicky Mac  wrote:
>
>> Hello again.]
>> not sure what you mean by "my profile".
>> following your suggestion, looks normal:
>>
>> C:\Users\Nick> python -c "import importlib;
>> print(importlib.find_loader('idlelib').path)"
>> C:\Python\Python35\lib\idlelib\__init__.pyc
>>
>> A search for idlelib shows this one plus one deep inside OpenOffice and a
>> Game.
>>
>> On 23 December 2015 at 21:20, eryk sun  wrote:
>>
>>> On Wed, Dec 23, 2015 at 1:51 PM, Nicky Mac  wrote:
>>> >
>>> > no sign of old Py2.7 anywhere :-
>>> >
>>> > C:\Users\Nick>python -c "import sys; print(*sys.path, sep='\n')"
>>> >
>>> > C:\Python\Python35\python35.zip
>>> > C:\Python\Python35\DLLs
>>> > C:\Python\Python35\lib
>>> > C:\Python\Python35
>>> > C:\Python\Python35\lib\site-packages
>>>
>>> The first blank entry is for the current directory. Do you maybe have
>>> an old "idlelib" directory in your profile?
>>>
>>> Print what it's attempting to load:
>>>
>>> python -c "import importlib;
>>> print(importlib.find_loader('idlelib').path)"
>>>
>>
>>
>>
>> --
>> Nick "Mac" McElwaine
>>
>
>
>
> --
> Nick "Mac" McElwaine
>



-- 
Nick "Mac" McElwaine
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-24 Thread Grant Edwards
On 2015-12-24, D'Arcy J.M. Cain  wrote:

> It reminds me of when one day people started claiming to be "building"
> computers and they didn't even own a soldering iron.

And don't get me started on those people who use those "integrated
circuits" instead of transistors, relays, and tubes...

-- 
Grant


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


Re: unable to open IDLE for Python3.50rc1 on windows10 64bit AMD

2015-12-24 Thread eryk sun
On Thu, Dec 24, 2015 at 8:52 AM, Nicky Mac  wrote:
> seems the user profile PATH is a registry entry, and was not updated when I
> deinstalled Python2.7
> still haven't  figured out how to change it - I will NOT attempy a regedit.

As to PATH on Windows, it's split into system and user components,
which get concatenated (system followed by user) when a profile is
loaded at logon. Persisted user environment variables are defined in
the user's "Environment" key. This is where PATH should be defined.

HKEY_CURRENT_USER\Environment

There's also the "Volatile Environment" key where the system stores
variables that are defined at logon such as USERNAME, USERPROFILE, and
a per-session subkey (e.g. "1" for session 1) that has values such as
SESSIONNAME.

HKEY_CURRENT_USER\Volatile Environment

HKEY_CURRENT_USER (HKCU) references the current user's hive, which is
loaded in HKEY_USERS. The entries in HKEY_USERS are named by user SIDs
(see "whoami /user"). The user's registry hive is loaded when logged
on interactively or otherwise by LoadUserProfile. The hive is
physically stored in the user profile directory in the hidden file
"%USERPROFILE%\NTUSER.DAT".

The system environment is first loaded by the session manager
(smss.exe) during boot, so it's a subkey of the session manager's
configuration.

HKEY_LOCAL_MACHINE\SYSTEM\
CurrentControlSet\Control\Session Manager\Environment

The HKLM\SYSTEM hive is located on the system volume at
"%SystemRoot%\System32\config\SYSTEM".

Don't use regedit to modify the environment unless you plan to reboot
the system. Tools that modify the environment know to broadcast a
WM_SETTINGCHANGE message to all top-level windows, which makes
Explorer reload its environment from the registry. Subsequent
processes started by Explorer inherit the updated environment.

>From the command line, use "set" to modify the current environment. If
you also want the change to be permanent, and for Explorer to be
notified, then use setx.exe.  In this case you still need cmd's
internal "set" in order to modify the current environment.

For example, first modify the current PATH.

C:\>set MYPATH=C:\Spam;C:\Eggs
C:\>set PATH=%PATH%;%MYPATH%

Next, inspect the user's PATH in the registry.

C:\>reg query HKCU\Environment /v PATH
HKEY_CURRENT_USER\Environment
PATHREG_EXPAND_SZ%USERPROFILE%\.dnx\bin

Run setx.exe to extend this value. Note that "^" is cmd's escape character.

C:\>setx MYPATH %MYPATH%
SUCCESS: Specified value was saved.

C:\>setx PATH ^%USERPROFILE^%\.dnx\bin;^%MYPATH^%
SUCCESS: Specified value was saved.

Verify that it was set correctly.

C:\>reg query HKCU\Environment
HKEY_CURRENT_USER\Environment
DNX_HOMEREG_SZ%USERPROFILE%\.dnx
PATHREG_EXPAND_SZ%USERPROFILE%\.dnx\bin;%MYPATH%
TEMPREG_EXPAND_SZ%USERPROFILE%\AppData\Local\Temp
TMPREG_EXPAND_SZ%USERPROFILE%\AppData\Local\Temp
MYPATHREG_SZC:\Spam;C:\Eggs

setx.exe sets the value's type as REG_EXPAND_SZ if it contains at
least two "%" characters. It's only well-defined for REG_EXPAND_SZ
values to depend on REG_SZ variables (or any system variable in a user
variable, since the system environment is loaded first). A registry
key is enumerated in arbitrary order (not alphabetic), but the system
enumerates the key in two passes, with REG_SZ variables loaded in the
first pass.

Note that Visual Studio mistakenly set DNX_HOME as a REG_SZ. Thus I
have the following useless environment variable:

C:\>echo %DNX_HOME% should have been set as REG_EXPAND_SZ.
%USERPROFILE%\.dnx should have been set as REG_EXPAND_SZ.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: unable to open IDLE for Python3.50rc1 on windows10 64bit AMD

2015-12-24 Thread Nicky Mac
sorry to be such a darned nuisance -
fixed the PATH to eliminate Py2.7 references but get same result:

C:\Users\Nick>path
PATH=C:\Python\Python35\Scripts\;C:\Python\Python35\;C:\ProgramData\Oracle\Java\javapath;C:\Program
Files\Broadcom\Broadcom 802.11 Network
Adapter;;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
Files (x86)\ATI Technologies\ATI.ACE\Core-Static;

C:\Users\Nick>python -m idlelib
C:\Python\Python35\python.exe: Error while finding spec for
'idlelib.__main__' (: bad magic number in 'idlelib':
b'\x03\xf3\r\n'); 'idlelib' is a package and cannot be directly executed

On 24 December 2015 at 14:52, Nicky Mac  wrote:

> what a horrible environment windows is to support anything!
> (I was a UNIX professional).
> seems the user profile PATH is a registry entry, and was not updated when
> I deinstalled Python2.7
> still haven't  figured out how to change it - I will NOT attempy a regedit.
>
> season's greetings
>
> On 24 December 2015 at 13:59, Nicky Mac  wrote:
>
>> Dear python Team
>> I think I've been wasting your time:
>>
>> C:\Users\Nick>path
>> PATH=C:\Python27\;C:\Python27\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\Program
>> Files\Broadcom\Broadcom 802.11 Network
>> Adapter;;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
>> Files (x86)\ATI
>> Technologies\ATI.ACE\Core-Static;C:\Python\Python35\Scripts\;C:\Python\Python35\
>>
>> somehow the new py3.5 has been added to the end, not the beginning.
>> guess this path is what you meant by "my profile".
>> I'll set about fixing it.
>> Meery christmas to you all
>> Nick
>>
>> On 24 December 2015 at 11:06, Nicky Mac  wrote:
>>
>>> Hello again.]
>>> not sure what you mean by "my profile".
>>> following your suggestion, looks normal:
>>>
>>> C:\Users\Nick> python -c "import importlib;
>>> print(importlib.find_loader('idlelib').path)"
>>> C:\Python\Python35\lib\idlelib\__init__.pyc
>>>
>>> A search for idlelib shows this one plus one deep inside OpenOffice and
>>> a Game.
>>>
>>> On 23 December 2015 at 21:20, eryk sun  wrote:
>>>
 On Wed, Dec 23, 2015 at 1:51 PM, Nicky Mac 
 wrote:
 >
 > no sign of old Py2.7 anywhere :-
 >
 > C:\Users\Nick>python -c "import sys; print(*sys.path, sep='\n')"
 >
 > C:\Python\Python35\python35.zip
 > C:\Python\Python35\DLLs
 > C:\Python\Python35\lib
 > C:\Python\Python35
 > C:\Python\Python35\lib\site-packages

 The first blank entry is for the current directory. Do you maybe have
 an old "idlelib" directory in your profile?

 Print what it's attempting to load:

 python -c "import importlib;
 print(importlib.find_loader('idlelib').path)"

>>>
>>>
>>>
>>> --
>>> Nick "Mac" McElwaine
>>>
>>
>>
>>
>> --
>> Nick "Mac" McElwaine
>>
>
>
>
> --
> Nick "Mac" McElwaine
>



-- 
Nick "Mac" McElwaine
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue12484] The Py_InitModule functions no longer exist, but remain in the docs

2015-12-24 Thread Anish Shah

Anish Shah added the comment:

@brett.cannon Thanks! I have updated the patch. I removed 
"_PyImport_FixupExtension" from docs.

--
Added file: http://bugs.python.org/file41404/issue12484.patch

___
Python tracker 

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



[issue20440] Use the Py_SETREF macro

2015-12-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 23296440b654 by Serhiy Storchaka in branch '2.7':
Issue #20440: Massive replacing unsafe attribute setting code with special
https://hg.python.org/cpython/rev/23296440b654

New changeset fd36d72f6030 by Serhiy Storchaka in branch '3.5':
Issue #20440: Massive replacing unsafe attribute setting code with special
https://hg.python.org/cpython/rev/fd36d72f6030

New changeset c4e8751ce637 by Serhiy Storchaka in branch 'default':
Issue #20440: Massive replacing unsafe attribute setting code with special
https://hg.python.org/cpython/rev/c4e8751ce637

--
nosy: +python-dev

___
Python tracker 

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



[issue20440] Use the Py_SETREF macro

2015-12-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Committed patches were generated with attached Coccinelle script.

--
Added file: http://bugs.python.org/file41401/py_setref.cocci

___
Python tracker 

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



[issue20440] Use the Py_SETREF macro

2015-12-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Following patch is manually crafted and covers the rest cases. It also replaces 
existing correct attribute replacing using a temporary variable with more 
compact call of the macro.

--
Added file: http://bugs.python.org/file41402/py_setref_extra.patch

___
Python tracker 

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



Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-24 Thread D'Arcy J.M. Cain
On Thu, 24 Dec 2015 10:47:04 -0500
Joel Goldstick  wrote:
> Not to be rude, but if your style of methodology for asking for help
> is indicative of your general attitude, and interest in learning to
> write software, you may be better served to find a new calling.  Its
> not a good profession for people who basically say "do this for me"

Or we wish it wasn't.  That seems to be the style today.  People claim
to be programmers who only search the net for snippets to plug into
their programs with no actual understanding.  Or, they download a
Wordpress theme and call themselves web designers.

It reminds me of when one day people started claiming to be "building"
computers and they didn't even own a soldering iron.

-- 
D'Arcy J.M. Cain
Vybe Networks Inc.
http://www.VybeNetworks.com/
IM:da...@vex.net VoIP: sip:da...@vybenetworks.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-24 Thread Chris Angelico
On Fri, Dec 25, 2015 at 3:14 AM, D'Arcy J.M. Cain
 wrote:
> It reminds me of when one day people started claiming to be "building"
> computers and they didn't even own a soldering iron.

Hey! Don't judge me just because I use my dad's! :)

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


Re: unable to open IDLE for Python3.50rc1 on windows10 64bit AMD

2015-12-24 Thread eryk sun
 On Thu, Dec 24, 2015 at 8:52 AM, Nicky Mac  wrote:
> seems the user profile PATH is a registry entry, and was not updated when I
> deinstalled Python2.7
> still haven't  figured out how to change it - I will NOT attempy a regedit.

I don't use the option to add the installation and Scripts directories
to PATH. It's a mess when installing multiple interpreters. I use the
py launcher [1] and virtual environments [2], and manually add .PY to
PATHEXT.

[1]: https://docs.python.org/3/using/windows.html#python-launcher-for-windows
[2]: https://docs.python.org/3/library/venv.html
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25933] Unhandled exception (TypeError) with ftplib in function retrbinary/retrlines causes inoperable behavior without crashing

2015-12-24 Thread SilentGhost

SilentGhost added the comment:

OK, here is the patch with the test that I think is exercising the issue.

--
keywords: +needs review, patch
stage:  -> patch review
Added file: http://bugs.python.org/file41403/issue25933.diff

___
Python tracker 

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



[issue24103] Use after free in xmlparser_setevents (1)

2015-12-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset deda5b5160d2 by Serhiy Storchaka in branch '2.7':
Issue #24103: Fixed possible use after free in ElementTree.iterparse().
https://hg.python.org/cpython/rev/deda5b5160d2

New changeset ed62cf0cf256 by Serhiy Storchaka in branch '3.5':
Issue #24103: Fixed possible use after free in ElementTree.XMLPullParser.
https://hg.python.org/cpython/rev/ed62cf0cf256

New changeset 8a14af800f96 by Serhiy Storchaka in branch 'default':
Issue #24103: Fixed possible use after free in ElementTree.XMLPullParser.
https://hg.python.org/cpython/rev/8a14af800f96

--
nosy: +python-dev

___
Python tracker 

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



[issue24103] Use after free in xmlparser_setevents (1)

2015-12-24 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
dependencies:  -Use the Py_SETREF macro
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



Re: need some basic help

2015-12-24 Thread Steven D'Aprano
On Thu, 24 Dec 2015 12:53 pm, Qurrat ul Ainy wrote:

> Hello,
> 
> Can someone please explain this code below. I am new at Python .
> Thanks
> 
> 
> def receive_messages(self, msgs, time):
>   for msg in msgs:
>  msg.set_recv_time(time)
>   self.msgs_received.extend(msgs)


This is a method belonging to a class. We don't know what the class is,
because you haven't shown it, so let's just call it "MyClass".

The method takes two arguments (msgs and time) plus a special
argument, "self", which represents the instance where the method is called.
So at some point, you must say:

instance = MyClass()

Do you understand object oriented programming? Have you programmed in any
other languages?

My *guess* is that the "msgs" argument is probably a list of messages:

the_messages = [first_message, second_message, third_message]

and the "time" argument is possibly a number (time in seconds?):

some_time = 125


Then you call the method:

instance.receive_messages(the_messages, some_time)


When you call the receive_messages method, the following happens:

- each of the messages are taken in turn, one at a time, and a method on
that message is called:

for msg in msgs:
msg.set_recv_time(time)

Translation:
for each message first_message, second_message, ...
call method "set_recv_time" with argument some_time

- then the original instance calls one of its own messages, probably to
store those messages:

self.msgs_received.extend(msgs)




I can't be more detailed, as I don't know how much programming experience
you have, or what the class that this method came from does.


-- 
Steven

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


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-24 Thread princeudo52
here is what i came up with 
Class BankAccount(object):
def_init_(self, balance):
self.Balance = balance
def deposit(self, amount):
self.Balance = amount
def withdraw(self,amount):
if(self.Balance += amount):
return invalid transaction
#but my challange now is :Create a subclass MinimumBalanceAccount of the 
BankAccount class.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: need some basic help

2015-12-24 Thread Andrew Farrell
This code snippet is a method on a class. What is a method? This chapter of
the book Think Python
 does a
good job of explaining it.
Without understanding this foundation, it isn't possible to really answer
your question, so definitely read at least that chapter.
Think Python was the book I first learned from and if you are new to
python, I recommend it among the other python tutorials to consider.

In this case, this method takes two things:
0) The object that it is a method of (by python convention, this is called
"self")
1) a collection of message objects (probably a list, maybe a tuple,
probably not a set)
2) a time
It then, goes through all of them and tells each one "you were received at
some particular time." by calling a method on each of the message objects.
The object that it is a method of seems to have a list of messages it has
received. So, this method sticks the collection of new message objects onto
the list of already-received messages.

On Wed, Dec 23, 2015 at 7:53 PM, Qurrat ul Ainy 
wrote:

> Hello,
>
> Can someone please explain this code below. I am new at Python .
> Thanks
>
>
> def receive_messages(self, msgs, time):
>   for msg in msgs:
>  msg.set_recv_time(time)
>   self.msgs_received.extend(msgs)
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Command line for silent Install & Uninstall

2015-12-24 Thread White, Dalton
Hi Support

I have seen many documents on the internet regarding installs of MSI but I only 
see the option to download exe's from your website. How can I get the MSI for 
Python version 3.5.1?

I am using ""python-3.5.1rc1-amd64.exe" /passive /uninstall" to uninstall the 
software but the uninstall screen just keeps coming up and disappearing. Do you 
have any solutions or fixes that you can offer me?

Thanks
Dalton
416-988-0662



If you have received this email in error, please let me know by return email so 
I can make sure it doesn't happen again. Because emails can contain 
confidential and privileged material, I'd ask for your help by deleting it and 
any attachments. Thanks!

We like to keep people up to date with information about new products and 
services at ATB or changes that could affect you. You can check out more about 
ATB and CASL at 
http://www.atb.com/important-information/privacy-security/Pages/ATB-and-CASL.aspx
 

If you would like to unsubscribe from our updates, please use this URL - 
http://www.atb.com/important-information/privacy-security/Pages/unsubscribe.aspx
 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't os.remove work on directories?

2015-12-24 Thread Laurent Delacroix
On 23/12/15 05:29, Random832 wrote:
> 
> This is surprising to anyone accustomed to the POSIX C remove
> function, which can remove either files or directories.  Is there
> any known rationale for this decision?
> 

Hello, in POSIX C the remove() function is actually rmdir() when called
on a directory: http://bit.ly/1NE1rfZ

I'm not sure about the rationale behind raising OSError if the argument
is a directory though. Maybe the "There should be one-- and preferably
only one --obvious way to do it." philosophy explains it. :-)

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


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-24 Thread Chris Angelico
On Thu, Dec 24, 2015 at 11:59 PM,   wrote:
> here is what i came up with
> Class BankAccount(object):
> def_init_(self, balance):
> self.Balance = balance
> def deposit(self, amount):
> self.Balance = amount
> def withdraw(self,amount):
> if(self.Balance += amount):
> return invalid transaction
> #but my challange now is :Create a subclass MinimumBalanceAccount of the 
> BankAccount class.

Step 1: Debug your code before you post it.

Step 2: Make sure that the way your code ends up is the same as the
way it started out. I suspect you have some of the above lines
indented, but that's getting lost.

Your code (a) will not compile, due to a complete lack of indentation;
(b) will not compile even if indented correctly, due to a misuse of an
'operator' that isn't actually an operator; (c) won't compile due to
invalid abuttal of tokens (did you intend to put quotes around
something?); (d) STILL won't compile because you misspelled a keyword;
and (e) won't do what you think it should, even once you make it
compile, because of logic errors. Don't move on to the second
challenge until you have mastered this first one.

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


can i subscribe python mailing list?

2015-12-24 Thread 우종민
   i want to subscribe mailing list

   [1][IMG]

References

   Visible links
   1. mailto:wjm0...@hanmail.net
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: unable to open IDLE for Python3.50rc1 on windows10 64bit AMD

2015-12-24 Thread Nicky Mac
Dear python Team
I think I've been wasting your time:

C:\Users\Nick>path
PATH=C:\Python27\;C:\Python27\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\Program
Files\Broadcom\Broadcom 802.11 Network
Adapter;;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
Files (x86)\ATI
Technologies\ATI.ACE\Core-Static;C:\Python\Python35\Scripts\;C:\Python\Python35\

somehow the new py3.5 has been added to the end, not the beginning.
guess this path is what you meant by "my profile".
I'll set about fixing it.
Meery christmas to you all
Nick

On 24 December 2015 at 11:06, Nicky Mac  wrote:

> Hello again.]
> not sure what you mean by "my profile".
> following your suggestion, looks normal:
>
> C:\Users\Nick> python -c "import importlib;
> print(importlib.find_loader('idlelib').path)"
> C:\Python\Python35\lib\idlelib\__init__.pyc
>
> A search for idlelib shows this one plus one deep inside OpenOffice and a
> Game.
>
> On 23 December 2015 at 21:20, eryk sun  wrote:
>
>> On Wed, Dec 23, 2015 at 1:51 PM, Nicky Mac  wrote:
>> >
>> > no sign of old Py2.7 anywhere :-
>> >
>> > C:\Users\Nick>python -c "import sys; print(*sys.path, sep='\n')"
>> >
>> > C:\Python\Python35\python35.zip
>> > C:\Python\Python35\DLLs
>> > C:\Python\Python35\lib
>> > C:\Python\Python35
>> > C:\Python\Python35\lib\site-packages
>>
>> The first blank entry is for the current directory. Do you maybe have
>> an old "idlelib" directory in your profile?
>>
>> Print what it's attempting to load:
>>
>> python -c "import importlib;
>> print(importlib.find_loader('idlelib').path)"
>>
>
>
>
> --
> Nick "Mac" McElwaine
>



-- 
Nick "Mac" McElwaine
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-24 Thread princeudo52
On Saturday, December 12, 2015 at 10:05:29 AM UTC+1, Harbey Leke wrote:
> Create a class called BankAccount
> 
> .Create a constructor that takes in an integer and assigns this to a 
> `balance` property.
> 
> .Create a method called `deposit` that takes in cash deposit amount and 
> updates the balance accordingly.
> 
> .Create a method called `withdraw` that takes in cash withdrawal amount and 
> updates the balance accordingly. if amount is greater than balance return 
> `"invalid transaction"`
> 
> .Create a subclass MinimumBalanceAccount of the BankAccount class
> 
> Please i need help on this i am a beginer into python programming.
> 
> 
> Also below is a test case given for this project 
> 
> 
> import unittest
> class AccountBalanceTestCases(unittest.TestCase):
>   def setUp(self):
> self.my_account = BankAccount(90)
> 
>   def test_balance(self):
> self.assertEqual(self.my_account.balance, 90, msg='Account Balance 
> Invalid')
> 
>   def test_deposit(self):
> self.my_account.deposit(90)
> self.assertEqual(self.my_account.balance, 180, msg='Deposit method 
> inaccurate')
> 
>   def test_withdraw(self):
> self.my_account.withdraw(40)
> self.assertEqual(self.my_account.balance, 50, msg='Withdraw method 
> inaccurate')
> 
>   def test_invalid_operation(self):
> self.assertEqual(self.my_account.withdraw(1000), "invalid transaction", 
> msg='Invalid transaction')
>   
>   def test_sub_class(self):
> self.assertTrue(issubclass(MinimumBalanceAccount, BankAccount), msg='No 
> true subclass of BankAccount')

please what is a balance property in OOP
-- 
https://mail.python.org/mailman/listinfo/python-list


SSL over TCP Client\server

2015-12-24 Thread Tal Bar-Or
Hi All ,

I need to write some basic tcp client/server that communicate over SSL
Its seems i managed to run the server side listen with SSL but i am missing the 
client part.
If someone could advice me how to saet the client will be appreciated
Thanks


Server side


class SingleTCPHandler(socketserver.BaseRequestHandler):
"One instance per connection.  Override handle(self) to customize action."


def handle(self):
try:


#print(self.server.serverset)
data = json.loads(self.request.recv(1024).decode('UTF-8').strip())
# process the data, i.e. print it:
#print(self.client_address)

print(data['AuthPass'],self.server.serverset['CryptKey'],self.server.serverset['Password'])
Authstart = 
AuthMec(data['AuthPass'],self.server.serverset['CryptKey'],self.server.serverset['Password'])
Authstart.DecPass()


# send some 'ok' back
#self.server.serverset['QuarantineIp']

self.request.sendall(bytes(json.dumps({'QuarantineIp':self.server.serverset['QuarantineIp'],'SERVERIP':self.client_address[0]}),
 'UTF-8'))
except Exception as e:
print("Exception wile receiving message: ", e)


class TcpSessionServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
# Ctrl-C will cleanly kill all spawned threads
daemon_threads = True
# much faster rebinding
allow_reuse_address = True
test = "test"

def __init__(self, server_address, RequestHandlerClass):
socketserver.TCPServer.__init__(self, server_address, 
RequestHandlerClass)
self.socket = ssl.wrap_socket(
self.socket, server_side=True, 
certfile="cert.pem",do_handshake_on_connect=False)
#read configuraiton and seve it as class member
serverinit = GetServerInfo()


Clent Side
===

class TcpClientConnect:
def __init__(self,Datapayload,EnforcementHost,SrvPort):
self.Datapayload = Datapayload
self.EnforcementHost = EnforcementHost
self.SrvPort = SrvPort

def ContactEnforcementHost(self):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((self.EnforcementHost, int(self.SrvPort)))
s.send(bytes(json.dumps(self.Datapayload), 'UTF-8'))
#Waiting for results
result = s.recv(1024)
txres =  result.decode('UTF-8')
print(txres)

jsresult = json.loads(txres)
print("%s"%jsresult)
s.close()

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


Bug in Python 3.5.1

2015-12-24 Thread nisthesecond
Dear Sir,
   I downloaded and installed Python 3.5.1 in Windows 10.
   The pip command was not part of it.
   In the future, can you kindly include numpy, scipy, and pygame as part of
   the Python release?
   I am a teacher trying to teach Python to my students.
   To get a working version of Python going is extremely tedious.
   Kind Regards,
   Nick Srinivasan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: unable to open IDLE for Python3.50rc1 on windows10 64bit AMD

2015-12-24 Thread Nicky Mac
Hello again.]
not sure what you mean by "my profile".
following your suggestion, looks normal:

C:\Users\Nick> python -c "import importlib;
print(importlib.find_loader('idlelib').path)"
C:\Python\Python35\lib\idlelib\__init__.pyc

A search for idlelib shows this one plus one deep inside OpenOffice and a
Game.

On 23 December 2015 at 21:20, eryk sun  wrote:

> On Wed, Dec 23, 2015 at 1:51 PM, Nicky Mac  wrote:
> >
> > no sign of old Py2.7 anywhere :-
> >
> > C:\Users\Nick>python -c "import sys; print(*sys.path, sep='\n')"
> >
> > C:\Python\Python35\python35.zip
> > C:\Python\Python35\DLLs
> > C:\Python\Python35\lib
> > C:\Python\Python35
> > C:\Python\Python35\lib\site-packages
>
> The first blank entry is for the current directory. Do you maybe have
> an old "idlelib" directory in your profile?
>
> Print what it's attempting to load:
>
> python -c "import importlib;
> print(importlib.find_loader('idlelib').path)"
>



-- 
Nick "Mac" McElwaine
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-24 Thread princeudo52
i am getting to believe that no one can provide a solution to this challenge, 
every-one here is just beating around the bush
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-24 Thread Chris Angelico
On Fri, Dec 25, 2015 at 1:17 AM,   wrote:
> i am getting to believe that no one can provide a solution to this challenge, 
> every-one here is just beating around the bush

It's not a question of 'can' but 'will'. We will not provide the
answer to your homework question. This has already been explained to
you.

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


Re: Bug in Python 3.5.1

2015-12-24 Thread Mark Lawrence

On 24/12/2015 00:57, nisthesec...@verizon.net wrote:

 Dear Sir,
I downloaded and installed Python 3.5.1 in Windows 10.
The pip command was not part of it.
In the future, can you kindly include numpy, scipy, and pygame as part of
the Python release?
I am a teacher trying to teach Python to my students.
To get a working version of Python going is extremely tedious.
Kind Regards,
Nick Srinivasan



pip is part of Python 3.5.1, I'd assume that you did not select it when 
you did the installion.  Installing third party modules with core Python 
is never going to happen.  However there are several distributions that 
do bundle things, see http://www.scipy.org/install.html


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Bug in Python 3.5.1

2015-12-24 Thread Cody Piersall
On Wed, Dec 23, 2015 at 6:57 PM,  wrote:
> Dear Sir,
>In the future, can you kindly include numpy, scipy, and pygame as part
of
>the Python release?
>Nick Srinivasan

Hello Nick,

Any time you want to install a Python package, the first thing you should
try is typing "pip install [package-name]".  If that doesn't work (and it
often doesn't), you should check [Christoph Golke's website] for the
package you're trying to install.

If you want to download Python and have numpy, scipy, and Python in one
installer, I recommend using [Anaconda].  You will still have to download
pygame yourself (I think).  Anaconda is a pretty big download, but the plus
side is that it comes with lots of packages so probably won't have to
install as much stuff.

There is no way that numpy, scipy, and pygame will become a part of the
Python release; that's why redistributors like Anaconda exist.

[Anaconda]: https://www.continuum.io/downloads#_windows
[Christoph Golke's website]: http://www.lfd.uci.edu/~gohlke/pythonlibs/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: unable to open IDLE for Python3.50rc1 on windows10 64bit AMD

2015-12-24 Thread eryk sun
On Thu, Dec 24, 2015 at 5:06 AM, Nicky Mac  wrote:
>
> not sure what you mean by "my profile".
> following your suggestion, looks normal:

I meant your profile directory, "C:\Users\Nick". But printing the
package path showed the problem is in your Python 3 installation
itself.

> C:\Users\Nick> python -c "import importlib;
> print(importlib.find_loader('idlelib').path)"
> C:\Python\Python35\lib\idlelib\__init__.pyc

This file should not exist. Python 3 stores .pyc files in a
__pycache__ subdirectory. It won't even run "idlelib\__init__.pyc" if
"idlelib\__init__.py" exists, so your installation is incomplete and
damaged. I suggest that you uninstall Python 3.5 and then completely
remove "C:\Python\Python35" before reinstalling.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-24 Thread Joel Goldstick
On Thu, Dec 24, 2015 at 9:39 AM, Chris Angelico  wrote:

> On Fri, Dec 25, 2015 at 1:17 AM,   wrote:
> > i am getting to believe that no one can provide a solution to this
> challenge, every-one here is just beating around the bush
>
> It's not a question of 'can' but 'will'. We will not provide the
> answer to your homework question. This has already been explained to
> you.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Generally, the best way to receive help is to provide your code written in
a way that is indented (plain text), provide the complete text of what you
are being asked to do in your class, and copy and paste any output or
exceptions.

You don't seem to be willing to do any of these things, and consequently
you can't be helped.  Also, what is up with the handful of email addresses
used to post your 'demands'.

Not to be rude, but if your style of methodology for asking for help is
indicative of your general attitude, and interest in learning to write
software, you may be better served to find a new calling.  Its not a good
profession for people who basically say "do this for me"

-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list