[issue17765] weakref.ref ignores a 'callback' keyword argument

2016-05-06 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> georg.brandl

___
Python tracker 

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



[issue26889] Improve Doc/library/xmlrpc.client.rst

2016-05-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 04250fc723e6 by Serhiy Storchaka in branch '3.5':
Issue #26889: Tweaked xmlrpc.client documentation.
https://hg.python.org/cpython/rev/04250fc723e6

New changeset 9bdec549bad3 by Serhiy Storchaka in branch 'default':
Issue #26889: Tweaked xmlrpc.client documentation.
https://hg.python.org/cpython/rev/9bdec549bad3

New changeset fb5bd513751f by Serhiy Storchaka in branch '2.7':
Issue #26889: Tweaked xmlrpclib documentation.
https://hg.python.org/cpython/rev/fb5bd513751f

--
nosy: +python-dev

___
Python tracker 

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



[issue26889] Improve Doc/library/xmlrpc.client.rst

2016-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you Terry.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
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



Re: Python is an Equal Opportunity Programming Language

2016-05-06 Thread John Wong
On Sat, May 7, 2016 at 12:04 AM, Chris Angelico  wrote:
>
>
> In the case of PyCon questions, I fully agree with it; there were
> enough women present that it wasn't a ridiculous suggestion, and it
> encourages people to speak up who might otherwise have kept quiet. But
> just because that worked well, it doesn't mean we should automatically
> enact quotas everywhere, as some sort of "gender/race/culture
> imbalance panacea", because it isn't.
>

I think it is a good call to ask if non-male attendees would be interested
in asking question. I didn't attend those PyCons so I don't know how many
male and female attendees lined up awaiting to ask Guido questions. If
there were 25 male and 1 female standing in the line, while I do admire
Guido (or just about anybody) encouraging more non-male to speak, is it
worth asking whether we place pressure on the females attendees if were to
say "hey look, we got a lot of male attendees asking, please more female
attendees." I totally understand there is a long history of females being
treated as inferior (even in America here!), but too much encouragement or
too eager to seek more females speaking is almost like saying females are
shy and can't speak up without the presence of a heroic voice.

I am a male and I am Asian so I am usually regarded as majority in the tech
world so I don't always feel underrepresented and can be biased here.
Recently I went to some company's website and on the career page I found a
banner photo full of white males and maybe 3-4 females in the pictures,
holding beers having a great smile posing for a group picture. It could be
really genuine, but I felt so uncomfortable immediately because (1) the
ratio of male:female is so out balanced, (2) I felt the company was selling
the "equal opportunity" sloan too hard. What I am saying is don't try so
hard, people will apply job if they want the job, regardless of gender and
ethnicity. Similarly, if females attendees want to ask questions, they
will. We shouldn't broadcast every single time "we gotta have more females
speaking, or more underrepresented people speaking."

When I am hanging out with my friends, whether they are male or female, I
don't really think of he/she. I think of them as friends, as human being,
no need to differentiate whether they are Mexican or Black or Asian. Just
human being. Sexual assault laws in some countries are pretty stupid in the
sense that female sexual assault offender would receive light punishment
compared to female offender. While social and history would justify such
law (because again, males historically dominated women), we still treat
people inferior by gender and ethnicity.

I don't know, this is a sensitive issue. People are either coerced to
believe in one kind of response, or perceive as anti-X if given a different
kind of response.

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


Re: Python is an Equal Opportunity Programming Language

2016-05-06 Thread Chris Angelico
On Sat, May 7, 2016 at 1:33 PM, Steven D'Aprano  wrote:
> On Sat, 7 May 2016 06:35 am, beliav...@aol.com wrote:
>
>> This not "equal opportunity". It is a quota system.
>
> I must ask, what do you think the phrase "quota system" means?
>
> Who is setting and enforcing this quota, and given that only about 1 in 20
> Python programmers is a woman, do you think men are seriously missing out
> on any opportunities?
>

The problem with quotas isn't "women don't deserve to be heard"
(because they most assuredly do!), but that a restriction can
sometimes force awkwardnesses that weren't there to start with. It's
unlikely to be an issue at PyCon, but the same problem has come up in
other contexts. A great summary comes from the TV show "Yes, Minister"
[1], in which the eponymous Minster wishes to promote a woman, and
aiming for 25% women in senior positions (a quota, exactly on par with
"alternating questions from men and women"). In that case, the
"quota-promoted" woman objected, specifically because she didn't want
to be part of some 25%, she wanted to go somewhere that would respect
her for her accomplishments.

So it's possible to disagree with the quota system without disagreeing
with the goal it's trying to accomplish (or, conversely, without
agreeing with the imbalance that it's trying to address). It's a
sensitive matter that has to be handled carefully.

In the case of PyCon questions, I fully agree with it; there were
enough women present that it wasn't a ridiculous suggestion, and it
encourages people to speak up who might otherwise have kept quiet. But
just because that worked well, it doesn't mean we should automatically
enact quotas everywhere, as some sort of "gender/race/culture
imbalance panacea", because it isn't.

ChrisA

[1] https://en.wikipedia.org/wiki/Equal_Opportunities_(Yes_Minister)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue22107] tempfile module misinterprets access denied error on Windows

2016-05-06 Thread Eryk Sun

Eryk Sun added the comment:

The Windows API loses information when mapping kernel status values to Windows 
error codes. For example, the following status values are all mapped to 
ERROR_ACCESS_DENIED:

STATUS_INVALID_LOCK_SEQUENCE   0xc01e
STATUS_INVALID_VIEW_SIZE   0xc01f
STATUS_ALREADY_COMMITTED   0xc021
STATUS_ACCESS_DENIED   0xc022
STATUS_PORT_CONNECTION_REFUSED 0xc041
STATUS_THREAD_IS_TERMINATING   0xc04b
STATUS_DELETE_PENDING  0xc056
STATUS_FILE_IS_A_DIRECTORY 0xc0ba
STATUS_FILE_RENAMED0xc0d5
STATUS_PROCESS_IS_TERMINATING  0xc10a
STATUS_CANNOT_DELETE   0xc121
STATUS_FILE_DELETED0xc123

Encrypting File System
STATUS_ENCRYPTION_FAILED   0xc28a
STATUS_DECRYPTION_FAILED   0xc28b
STATUS_NO_RECOVERY_POLICY  0xc28d
STATUS_NO_EFS  0xc28e
STATUS_WRONG_EFS   0xc28f
STATUS_NO_USER_KEYS0xc290

STATUS_ACCESS_DENIED is from a failed NtAccessCheck. STATUS_FILE_IS_A_DIRECTORY 
is from trying to open a directory as a file, because NT doesn't allow 
accessing the anonymous data stream of a directory, such as "dirname::$DATA", 
which is the same as trying to open "dirname" as a file. It only allows 
creating a named data stream for a directory, such as 
"dirname:streamname:$DATA".

The original status value may still be available, but only by calling the 
undocumented runtime library function, RtlGetLastNtStatus, which was added in 
XP (NT 5.1). After a failed system call, the Windows base API calls 
BaseSetLastNTError, which calls RtlNtStatusToDosError to get the Win32/DOS 
error code for a given NT status value. This in turn caches the last NT status 
in the LastStatusValue field of the thread environment block (TEB). 
RtlGetLastNtStatus gets this value from the TEB.

Possibly PyErr_SetExcFromWindowsErrWithFilenameObjects could capture the most 
recent kernel status value from RtlGetLastNtStatus(), to add this as a new 
"ntstatus" attribute of OSError. This wouldn't always be meaningful, since the 
thread's LastErrorValue (returned by GetLastError) isn't always related to a 
failed system call, but it can help in cases such as this, to distinguish a 
genuine denial of access from some other failure, and without suffering from 
race conditions. 

For example, I added a "testdir" subdirectory to a directory and then modified 
the DACL of the parent directory to deny write/append access for all users. The 
following experiment checks the NT status using ctypes:

STATUS_ACCESS_DENIED = ctypes.c_long(0xC022).value
STATUS_FILE_IS_A_DIRECTORY = ctypes.c_long(0xC0BA).value

ntdll = ctypes.WinDLL('ntdll')

try: open('testdir', 'w')
except: status_dir = ntdll.RtlGetLastNtStatus()

try: open('test', 'w')
except: status_access = ntdll.RtlGetLastNtStatus()

>>> status_dir == STATUS_FILE_IS_A_DIRECTORY
True
>>> status_access == STATUS_ACCESS_DENIED
True

Obviously using ctypes isn't recommended, since the status value needs to be 
captured ASAP after the call fails, so here's an example in C:

#define UNICODE
#include 
#include 
#include 

typedef NTSTATUS (NTAPI *RTLGETLASTNTSTATUS)(VOID);

int main()
{
HMODULE hNtdll = GetModuleHandle(L"ntdll");
RTLGETLASTNTSTATUS RtlGetLastNtStatus = (RTLGETLASTNTSTATUS)
GetProcAddress(hNtdll, "RtlGetLastNtStatus");

if (_open("testdir", _O_CREAT | _O_EXCL) == -1)
printf("status_dir: %#08x\n", RtlGetLastNtStatus());

if (_open("test", _O_CREAT | _O_EXCL) == -1)
printf("status_access: %#08x\n", RtlGetLastNtStatus());
 
   return 0;
}

output:

status_dir: 0xc0ba
status_access: 0xc022

--

___
Python tracker 

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



Re: Python is an Equal Opportunity Programming Language

2016-05-06 Thread Steven D'Aprano
On Sat, 7 May 2016 06:35 am, beliav...@aol.com wrote:

> This not "equal opportunity". It is a quota system.

I must ask, what do you think the phrase "quota system" means?

Who is setting and enforcing this quota, and given that only about 1 in 20
Python programmers is a woman, do you think men are seriously missing out
on any opportunities?


> It's my 
> impression that in the U.S., Asians are over-represented among programmers
> relative to their share of the population and that whites and especially
> blacks are under-represented. Should we impose racial quotas on questions
> at conferences and call that "equal opportunity" as well?

I don't know. Are there systematic social forces that discourage whites or
blacks from taking up programming?

With an AOL email address, you're probably in the USA, and with an email
username like "beliavsky" I'm guessing you're probably Chinese. Nah just
kidding, you're probably of Eastern European or Russian ancestry, and
probably very white indeed.

- Do you feel systematically excluded and biased against because of your
skin colour?

- Do white-fellas like yourself find yourself repeatedly missing out on
opportunities because employers and managers bypass you as soon as they
realise you are white?

- When you do manage to find a job, do you feel that employers and managers
consistently hold you to a higher standard than your Asian colleagues,
expecting you to work twice as hard to get half the recognition?

- Do you get patronised by your colleagues because you're just a whitey?

- Do you find that there is a systematic and repeating assumption that
white-fellas like you can't program? Do people review your code with "It's
not bad, for a whitey"?

- Do you find that even when you are on an hourly rate, not a salary, you
consistently get offered lower pay for the same work as your Asian
colleagues?

- During staff meetings and conferences, do you find that your Asian
colleagues form cliques that exclude you, preventing you from establishing
the sort of networks that a professional needs?


If you can answer "Yes" to four or more of those questions, then perhaps
there is a case for something to combat the overwhelming anti-white racism
that you're suffering from.


-- 
Steven

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


Re: A fun python CLI program for all to enjoy!

2016-05-06 Thread MRAB

On 2016-05-07 00:58, DFS wrote:

On 5/6/2016 7:29 PM, Ethan Furman wrote:

On 05/06/2016 04:12 PM, DFS wrote:

On 5/6/2016 4:30 PM, MRAB wrote:



   If you don't want to use the 'with' statement, note that closing the
file is:

   f.close()

   It needs the "()"!


I used close() in 1 place, but close without parens in 2 other places.
So it works either way.  Good catch.


No, it doesn't.  `f.close` simple returns the close function, it doesn't
call it.  The "it works" was simply because Python closed the files for
you later.

Not a big deal in a small program like this, but still a mistake.



Yes.

Check out the answer by 'unutbu' here:

http://stackoverflow.com/questions/1832528/is-close-necessary-when-using-iterator-on-a-python-file-object

He says "I...checked /proc/PID/fd for when the file descriptor was
closed. It appears that when you break out of the for loop, the file is
closed for you."


If you read the comments for that answer, you'll find the explanation.


Improper f.close didn't seem to affect any of the files my program wrote
- and I checked a lot of them when I was writing the code.

Maybe it worked because the last time the file was written to was in a
for loop, so I got lucky and the files weren't truncated?  Don't know.

Did you notice any other gotchas in the program?



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


Re: A fun python CLI program for all to enjoy!

2016-05-06 Thread DFS

On 5/6/2016 7:29 PM, Ethan Furman wrote:

On 05/06/2016 04:12 PM, DFS wrote:

On 5/6/2016 4:30 PM, MRAB wrote:



   If you don't want to use the 'with' statement, note that closing the
file is:

   f.close()

   It needs the "()"!


I used close() in 1 place, but close without parens in 2 other places.
So it works either way.  Good catch.


No, it doesn't.  `f.close` simple returns the close function, it doesn't
call it.  The "it works" was simply because Python closed the files for
you later.

Not a big deal in a small program like this, but still a mistake.



Yes.

Check out the answer by 'unutbu' here:

http://stackoverflow.com/questions/1832528/is-close-necessary-when-using-iterator-on-a-python-file-object

He says "I...checked /proc/PID/fd for when the file descriptor was 
closed. It appears that when you break out of the for loop, the file is 
closed for you."


Improper f.close didn't seem to affect any of the files my program wrote 
- and I checked a lot of them when I was writing the code.


Maybe it worked because the last time the file was written to was in a 
for loop, so I got lucky and the files weren't truncated?  Don't know.


Did you notice any other gotchas in the program?


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


Re: python, ctypes and GetIconInfo issue

2016-05-06 Thread eryk sun
On Fri, May 6, 2016 at 9:49 AM,   wrote:
>
> In your example you used a base class
> and ICONINFO well as ICONINFOEX inherit it.
> As the members of ICONINFO are part of ICONINFOEX
> couldn't we do something like
>
> class ICONINFO_BASE(ctypes.Structure):
> def __del__(self, ):
> if self.hbmMask:
> gdi32.DeleteObject(self.hbmMask)
> self.hbmMask = None
> if self.hbmColor:
> gdi32.DeleteObject(self.hbmColor)
> self.hbmColor = None
>
> class ICONINFO(ICONINFO_BASE):
> _fields_ = (('fIcon',wintypes.BOOL),
> ('xHotspot', wintypes.DWORD),
> ('yHotspot', wintypes.DWORD),
> ('hbmMask',  wintypes.HBITMAP),
> ('hbmColor', wintypes.HBITMAP))
>
> class ICONINFOEX(ICONINFO):
> _fields_ = (('cbSize',wintypes.DWORD),
> # ('fIcon', wintypes.BOOL),
> # ('xHotspot',  wintypes.DWORD),
> # ('yHotspot',  wintypes.DWORD),
> # ('hbmMask',   wintypes.HBITMAP),
> # ('hbmColor',  wintypes.HBITMAP),
> ('wResID',wintypes.WORD),
> ('szModName', wintypes.WCHAR * MAX_PATH),
> ('szResName', wintypes.WCHAR * MAX_PATH))

In this case, cbSize field will be offset after hbmColor:

>>> ICONINFOEX.hbmColor.offset
24
>>> ICONINFOEX.cbSize.offset
32

A struct subclass appends its fields to the base class fields. In
theory, you can do this in some cases, but in practice I don't
recommend it (see below).

For example, look at SHARE_INFO_0 [1], SHARE_INFO_1 [2], and
SHARE_INFO_2 [3], which are used to query different levels of
information about network shares.

[1]: https://msdn.microsoft.com/en-us/library/bb525402
[2]: https://msdn.microsoft.com/en-us/library/bb525407
[3]: https://msdn.microsoft.com/en-us/library/bb525408

It can help to maintain a consistent type hierarchy, such as in the
following answer that I wrote to list network shares on Windows:

http://stackoverflow.com/a/36848031/205580

When ctypes checks the type of a pointer argument, it first checks
whether its _type_ is a subclass of the _type_ of the corresponding
pointer type in argtypes. If not, it falls back on checking whether
the pointer argument itself is an instance of the argtypes pointer
type. Similarly, for a byref() argument it checks whether the referent
is an instance of the _type_ of the argtypes pointer type. Maintaining
a consistent type hierarchy provides type safety without having to
tediously cast pointers.

However, I don't recommend subclassing to append _fields_ because it
has a bug. The code that updates the StgDictObject (i.e. the subclass
of dict used by ctypes types for FFI storgage info) for structs and
union types doesn't doesn't properly initialize the ffi_type elements
array. The length field of the stgdict needs to be the total number of
fields, inclusive of all base classes, in order to copy the entire
ffi_type elements array from the base class. However, storing the
total length in the stgdict's length field would require rewriting the
way an instance of a struct is recursively initialized over the base
classes.

This bug affects passing structs by value. This isn't common (passing
unions by value isn't even supported), so I haven't bothered to submit
a patch for this. Here's an example crash on 64-bit Linux:

test.c:

#include 

typedef struct _data_t {
int x, y, z;
} data_t;

int test(data_t d) {
printf("%d, %d, %d\n", d.x, d.y, d.z);
return 0;
}

test.py:

from ctypes import *

lib = CDLL('./test.so')

class A(Structure):
_fields_ = (('a', c_int), ('b', c_int), ('c', c_int),)

class B(Structure):
_fields_ = (('a', c_int),)
class C(B):
_fields_ = (('b', c_int),)
class D(C):
_fields_ = (('c', c_int),)

print('test A')
lib.test(A(42, 84, 168))

print('test D')
lib.test(D(42, 84, 168))

output:
test A
42, 84, 168
test D
Aborted
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python, ctypes and GetIconInfo issue

2016-05-06 Thread eryk sun
On Fri, May 6, 2016 at 8:36 AM,   wrote:
>
>> Please avoid windll. It caches the loaded library, which in turn
>> caches function pointers. So all packages that use windll.user32 are
>> potentially stepping on each others' toes with mutually incompatible
>> function prototypes. It also doesn't allow configuring
>> use_last_error=True to enable ctypes.get_last_error() for WinAPI
>> function calls.
> I assume you are referring to this block of code
>
> GetIconInfo = windll.user32.GetIconInfo
> GetIconInfo.argtypes   = [HICON, POINTER(ICONINFO)]
> GetIconInfo.restype= BOOL
> GetIconInfo.errcheck   = ErrorIfZero
>
> where as you use
>
> user32 = ctypes.WinDLL('user32', use_last_error=True)
> user32.GetIconInfoExW.errcheck = check_bool
> user32.GetIconInfoExW.restype = wintypes.BOOL
> user32.GetIconInfoExW.argtypes = (
> wintypes.HICON, # _In_  hIcon
> PICONINFOEX,)   # _Out_ piconinfoex
>
> I've checked ctype docu included in python but don't find any hint about your 
> concerns.
> May I ask you, do you know additional documents/sites which I can use to get 
> a better
> understanding about caching issue? Or did I miss something from used 
> documentation?

You haven't missed anything in the documentation. The ctypes docs need
work, and some of the examples are bad, if not wrong. For example, the
GetModuleHandleA examples incorrectly handle the pointer result
because they were never updated for 64-bit Windows. One can't use a
Python function as the restype with a C function that returns a
pointer because it will be truncated to a C int. Whoever wrote the
GetModuleHandleA examples either doesn't know how this feature is
implemented in ctypes (probably not, since I think Thomas Heller wrote
the example), or doesn't know that a Windows HMODULE is a pointer to
the module's base address, or was just writing sloppy code in the era
of 32-bit Windows.

In this case, look at the CDLL [1] and LibraryLoader [2] classes. Note
how CDLL.__getattr__ caches function pointers using setattr(self,
name, func). Note how LibraryLoader.__getattr__  caches libraries
using setattr(self, name, dll), and how it instantiates the library
using self._dlltype(name), with no way to specify use_last_error=True.
This has caused real problems for projects such as colorama (fixed)
and pyreadline (still broken), and I've seen potential problems in
several other projects that naively copy the cdll and windll examples
from the docs. It's not their fault. The docs are just bad on this
subject.

[1]: https://hg.python.org/cpython/file/v3.5.1/Lib/ctypes/__init__.py#l314
[2]: https://hg.python.org/cpython/file/v3.5.1/Lib/ctypes/__init__.py#l410

>> Using __del__ is convenient, but note that you can't
>> reuse an instance without manually calling DeleteObject on the
>> bitmaps.
>
> Don't understand this. Isn't this covered by your example in base class?

I'm talking about reusing an instance, to avoid the cost of repeated
allocation and deallocation. For example:

info = ICONINFOEX()
for hIcon in hIcons:
user32.GetIconInfoExW(hIcon, ctypes.byref(info))
print('fIcon: %d' % info.fIcon)
print('wResID   : %d' % info.wResID)
print('szModName: %s' % info.szModName)
gdi32.DeleteObject(info.hbmMask)
gdi32.DeleteObject(info.hbmColor)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A fun python CLI program for all to enjoy!

2016-05-06 Thread Ethan Furman

On 05/06/2016 04:12 PM, DFS wrote:

On 5/6/2016 4:30 PM, MRAB wrote:



   If you don't want to use the 'with' statement, note that closing the
file is:

   f.close()

   It needs the "()"!


I used close() in 1 place, but close without parens in 2 other places.
So it works either way.  Good catch.


No, it doesn't.  `f.close` simple returns the close function, it doesn't 
call it.  The "it works" was simply because Python closed the files for 
you later.


Not a big deal in a small program like this, but still a mistake.

--
~Ethan~

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


Re: A fun python CLI program for all to enjoy!

2016-05-06 Thread DFS

On 5/6/2016 4:30 PM, MRAB wrote:

On 2016-05-06 20:10, DFS wrote:

getAddresses.py

Scrapes addresses from www.usdirectory.com and stores them in a SQLite
database, or writes them to text files for mailing labels, etc

Now, just by typing 'fast food Taco Bell  10 db all' you can find
out how many Taco Bells are within 10 miles of you, and store all the
addresses in your own address database.

No more convoluted Googling, or hitting the 'Next Page' button, or
fumbling with the Yellow Pages...

Note: the db structure is flat on purpose, and the .csv files aren't
quote delimited.

Put the program in its own directory.  It creates the SQLite database
there, and writes files there, too.

Reviews of code, bug reports, criticisms, suggestions for improvement,
etc are all welcome.


OK, you asked for it... :-)

1. It's shorter and clearer not to compare with True or False:

   if verbose:

   and:

   if not dupeRow:



Done.  It will take some getting used to, though.  I like that it's 
shorter, but I could do the same in VBA and almost always chose not to.





2. You can print a blank line with an empty print statement:

   print


Done.  I actually like the way print  looks better than print ""




3. When looking for unique items, a set is a better choice than a list:

   addrCheck = set()

   def addrUnique(addr):
   if addr not in addrCheck:
   x = True
   addrCheck.add(addr)
   else:
   x = False
   return x


Done.

I researched this just now on StackOverflow:

"Sets are significantly faster when it comes to determining if an object 
is present in the set"

and
"lists are very nice to sort and have order while sets are nice to use 
when you don't want duplicates and don't care about order."


The speed difference won't matter here in my little app, but it's better 
to use the right construct for the job.





4. Try string formatting instead multiple concatenation:

   print "%s arguments" % argCnt



You're referring to this line:
print str(argCnt) + " arguments"

Is there a real benefit of using string formatting here?  (other than 
the required str() conversion)





5. Strings have a .join method, and when you combine it with string
slicing:

   keyw = "+".join(sys.argv[1 : argCnt - 5])



Slick.  Works a treat, and saved 2 lines of code.  String handling is 
another area in which python shines compared to VB.




6. Another example of string formatting:

   search = "%s %s %s %s %s" % (keyw, cityzip, state, miles, addrWant)


Done.  It's shorter, and doesn't require the str() conversion I had to 
do on several of the items.


If I can remember to use it, it should eliminate these:
"TypeError: cannot concatenate 'str' and 'int' objects"




7. It's recommended to use the 'with' statement when handling files:

   with open(webfile, "w") as f:
   if store == "csv":
   f.write("Name,Address,CityStateZip\n")



Done.  I read that using 'with' means Python closes the file even if an 
exception occurs.  So a definite benefit.





   If you don't want to use the 'with' statement, note that closing the
file is:

   f.close()

   It needs the "()"!


I used close() in 1 place, but close without parens in 2 other places. 
So it works either way.  Good catch.


(it's moot now: all 'f.open()/f.close()' replaced by 'with open()')




8. When using SQL, you shouldn't try to insert the values yourself; you
should use parametrised queries:

   cSQL = "DELETE FROM addresses WHERE datasrc = ? AND search = ?;"
   if verbose:
   print cSQL
   db.execute(cSQL, (datasrc, search))
   conn.commit()

It'll insert the values where the "?" are and will do any necessary
quoting itself. (Actually, some drivers use "?", others use "%s", so if
it doesn't work with one, try the other.)

The way you wrote it, it would fail if a value contained a "'". It's
that kind of thing that leads to SQL injection attacks.


Fixed.

You'll notice later on in the code I used the parameterized method for 
INSERTS.  I hate the look of that method, but it does make dealing with 
apostrophes easier, and makes it safer as you say.





Thanks for the code review, RMAB.  Good improvements.


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


Re: Whittle it on down

2016-05-06 Thread DFS

On 5/6/2016 11:44 AM, Peter Otten wrote:

DFS wrote:


There are up to 4 levels of categorization:



http://www.usdirectory.com/cat/g0 shows 21 Level 1 categories, and 390
Level 2.  To get the Level 3 and 4 you have to drill-down using the
hyperlinks.

How to do it in python code is beyond my skills at this point.  Get the
hrefs and load them and parse, then get the next level and load them and
parse, etc.?


Yes, that should work ;)



How about you do it, and I'll tell you if you did it right?

ha!




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


[issue26889] Improve Doc/library/xmlrpc.client.rst

2016-05-06 Thread Terry J. Reedy

Terry J. Reedy added the comment:

The corrected link works.  I agree with deleting a bad sentence if you cannot 
fix it.  I think you can go ahead and apply as is.

--

___
Python tracker 

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



Re: Python is an Equal Opportunity Programming Language

2016-05-06 Thread alex wright
It seems like it would be equal opportunity between sexes.  1:1 opportunity
to ask based on apparent sex.  It is not equal representation necessarily.
On May 6, 2016 5:53 PM, "beliavsky--- via Python-list" <
python-list@python.org> wrote:

> On Friday, May 6, 2016 at 5:07:28 PM UTC-4, Ethan Furman wrote:
> > On 05/06/2016 01:35 PM, beliavsky--- via Python-list wrote:
> >
> > > Most of [Guido's] keynote at that conference was answering questions
> from
> >  > the people who had attended. And he actually said, "Let's alternate
> > between
> >  > men and women asking questions."On the second day of the conference,
> > he was
> >  > wearing a shirt from PyLadies, another nonprofit like Django Girls
> > that helps
> >  > women learn how to program on Python.
> > >
> > > *
> > >
> > > This not "equal opportunity". It is a quota system.
> >
> > It's a corrective action, a way of getting men accustomed to listening
> > to women and hearing good ideas and questions from them, and a way to
> > accustom women to speaking in (currently) male dominated groups.
>
> It's silly to say that just because a group is over-represented that it
> "dominates". If a conference has more Asians than whites does that
> necessarily make it Asian-dominated?
>
> > And it is far more equal opportunity than having 25 males ask questions
> > and only one or two females.
>
> Not if there are 25 males with questions and only one or two females with
> questions. Among the people who have questions, you could choose randomly.
> You and Terry Reedy misuse the term "equal opportunity".
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26934] android: test_faulthandler fails

2016-05-06 Thread Terry J. Reedy

Terry J. Reedy added the comment:

The 8 failures are all because exitcode is 0 when it should not be.

self.assertNotEqual(exitcode, 0)
AssertionError: 0 == 0

--
nosy: +terry.reedy

___
Python tracker 

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



[issue26969] ascynio should provide a policy to address pass-loop-everywhere problem

2016-05-06 Thread Guido van Rossum

Guido van Rossum added the comment:

FWIW asyncio's own test suite makes sure that the loop is indeed passed
everywhere by setting the default loop to None. If a library chooses to
pass the loop around like this it should structure its tests the same way.

--

___
Python tracker 

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



[issue26911] lib2to3/tests/pytree_idempotency.py has broken imports

2016-05-06 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I decided that I should leave the scope of this issue as it was and close it as 
fixed.

--
assignee:  -> terry.reedy
resolution:  -> fixed
stage: needs patch -> resolved
status: open -> closed
title: lib2to3/tests/pytree_idempotency.py does not run -> 
lib2to3/tests/pytree_idempotency.py has broken imports
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



[issue26912] Broken imports in test/test_email/torture_test.py, test_asian_codecs.py) has a broken import

2016-05-06 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I also removed try to import the deleted support.TestSkipped.  I temporarily 
commented out the SkipTest replacement so the module would run, create the test 
class, run it, and fail.

I believe the import of run_unittest and the associated test_main, etc, can be 
deleted, but that is another issue.

--
assignee:  -> terry.reedy
resolution:  -> fixed
stage: needs patch -> resolved
status: open -> closed

___
Python tracker 

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



Re: Python is an Equal Opportunity Programming Language

2016-05-06 Thread beliavsky--- via Python-list
On Friday, May 6, 2016 at 5:07:28 PM UTC-4, Ethan Furman wrote:
> On 05/06/2016 01:35 PM, beliavsky--- via Python-list wrote:
> 
> > Most of [Guido's] keynote at that conference was answering questions from
>  > the people who had attended. And he actually said, "Let's alternate 
> between
>  > men and women asking questions."On the second day of the conference, 
> he was
>  > wearing a shirt from PyLadies, another nonprofit like Django Girls 
> that helps
>  > women learn how to program on Python.
> >
> > *
> >
> > This not "equal opportunity". It is a quota system.
> 
> It's a corrective action, a way of getting men accustomed to listening 
> to women and hearing good ideas and questions from them, and a way to 
> accustom women to speaking in (currently) male dominated groups.

It's silly to say that just because a group is over-represented that it 
"dominates". If a conference has more Asians than whites does that necessarily 
make it Asian-dominated?
 
> And it is far more equal opportunity than having 25 males ask questions 
> and only one or two females.

Not if there are 25 males with questions and only one or two females with 
questions. Among the people who have questions, you could choose randomly. You 
and Terry Reedy misuse the term "equal opportunity".
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26912] Broken imports in test/test_email/torture_test.py, test_asian_codecs.py) has a broken import

2016-05-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset e7da216ba17c by Terry Jan Reedy in branch '3.5':
Issue 26912: fix broken imports in test_email package.
https://hg.python.org/cpython/rev/e7da216ba17c

--
nosy: +python-dev

___
Python tracker 

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



[issue16113] Add SHA-3 and SHAKE (Keccak) support

2016-05-06 Thread Christian Heimes

Christian Heimes added the comment:

This patch implements SHA-3 and SHAKE for Python 3.6. The algorithm is provided 
by a slightly modified copy of the Keccak Code Package. I had to replace C++ 
comments and perform some minor cleanups.

--
stage: needs patch -> patch review
Added file: 
http://bugs.python.org/file42764/SHA3-and-SHAKE-support-for-Python.patch

___
Python tracker 

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



Re: Python is an Equal Opportunity Programming Language

2016-05-06 Thread Ethan Furman

On 05/06/2016 01:35 PM, beliavsky--- via Python-list wrote:


Most of [Guido's] keynote at that conference was answering questions from
> the people who had attended. And he actually said, "Let's alternate 
between
> men and women asking questions."On the second day of the conference, 
he was
> wearing a shirt from PyLadies, another nonprofit like Django Girls 
that helps

> women learn how to program on Python.


*

This not "equal opportunity". It is a quota system.


It's a corrective action, a way of getting men accustomed to listening 
to women and hearing good ideas and questions from them, and a way to 
accustom women to speaking in (currently) male dominated groups.


And it is far more equal opportunity than having 25 males ask questions 
and only one or two females.


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


[issue26912] Broken imports in test/test_email/torture_test.py, test_asian_codecs.py) has a broken import

2016-05-06 Thread Terry J. Reedy

Terry J. Reedy added the comment:

As with #26911, no 'test_' prefix means 'run by hand'.  I will make the two 
simple fixes, as well as delete 'from types import ListType' (ListType is list, 
and removed in 3.x).  But I will not try to run the torture test, hence no 
guarantee that it will run after import.

--
nosy: +terry.reedy
stage:  -> needs patch
title: test/test_email/torture_test.py (and test_asian_codecs.py) has a broken 
import -> Broken imports in test/test_email/torture_test.py, 
test_asian_codecs.py) has a broken import
type: compile error -> behavior

___
Python tracker 

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



[issue16113] Add SHA-3 and SHAKE (Keccak) support

2016-05-06 Thread Christian Heimes

Changes by Christian Heimes :


--
hgrepos:  -152

___
Python tracker 

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



[issue26969] ascynio should provide a policy to address pass-loop-everywhere problem

2016-05-06 Thread Yury Selivanov

Yury Selivanov added the comment:

>> Update some places in asyncio where we currently use "get_event_loop()", 
>> such as Future constructor, Task.current_task, etc.

> Yury, do you have an idea how it could be done?

I think I do.  To keep the backwards compatibility, we'll need to update the 
"get_event_loop()" function as follows:

  def get_event_loop():
 loop = _running_loop.loop
 if loop is None:
 loop = get_event_loop_old_impl()
 return loop

No need to actually update Future or Task or any other asyncio code.

The get_running_loop() would look like this:

  def get_running_loop():
 loop = _running_loop.loop
 if loop is None:
 raise RuntimeError('no running event loop')
 return loop

--

___
Python tracker 

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



[issue22234] urllib.parse.urlparse accepts any falsy value as an url

2016-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you Luiz for your testing.

> __main__:1: DeprecationWarning: Use of '' is deprecated

It is bad that a warning is emitted for default value.

> Will bytes be deprecated if used as a default_schema?

No, only using empty bytes schema with string url is deprecated (because it 
works now). Using non-empty bytes schema with string url just causes an error.

> Shouldn't it complain that the types are different?

This special case is left for compatibility with wrappers.

> __main__:1: DeprecationWarning: Use of [] is deprecated

The warning should not be emitted for the value that the user did not provide.

If go by the way of strong deprecation, the patch needs reworking. But this is 
a way of overcomplication.

Since as pointed Antti, only using str, bytes and bytearray is documented, I 
think we can ignore the breakage for other types.

--

___
Python tracker 

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



[issue26969] ascynio should provide a policy to address pass-loop-everywhere problem

2016-05-06 Thread R. David Murray

R. David Murray added the comment:

The way I avoid the errors of failing to always pass the loop through in my 
application library, currently, is to run my tests in a thread with no event 
loop set up, so that get_event_loop will raise an error.  Take that for what it 
is worth, since I don't claim to know what best practices are in asyncio 
programming.

--

___
Python tracker 

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



[issue26969] ascynio should provide a policy to address pass-loop-everywhere problem

2016-05-06 Thread Ilya Kulakov

Ilya Kulakov added the comment:

> Update some places in asyncio where we currently use "get_event_loop()", such 
> as Future constructor, Task.current_task, etc.

Yury, do you have an idea how it could be done?

--

___
Python tracker 

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



[issue26939] android: test_functools hangs on armv7

2016-05-06 Thread Xavier de Gaye

Xavier de Gaye added the comment:

Forgot to say that the backtraces for test_threading and test_importlib were 
obtained with the patch applied while they were hanging.

--

___
Python tracker 

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



Re: Python is an Equal Opportunity Programming Language

2016-05-06 Thread beliavsky--- via Python-list
On Thursday, May 5, 2016 at 3:00:01 PM UTC-4, Terry Reedy wrote:
> https://motherboard.vice.com/blog/python-is-an-equal-opportunity-programming-language
> 
> from an 'Intel(R) Software Evangelist'
> -- 
> Terry Jan Reedy

>From the link:

MB: What is it about Python that makes it friendly to women? Is it something 
about the actual language itself? Or is it more of a subcultural thing within 
the community?

DS: One thing that I think causes this is the founder of the Python project, a 
guy named Guido van Rossum. He's referred to as the "BDFL"--the Benevolent 
Dictator for Life. The way to think of him is like Linus Torvalds of Linux.

Most of his keynote at that conference was answering questions from the people 
who had attended. And he actually said, "Let's alternate between men and women 
asking questions."On the second day of the conference, he was wearing a shirt 
from PyLadies, another nonprofit like Django Girls that helps women learn how 
to program on Python.

*

This not "equal opportunity". It is a quota system. It's my 
impression that in the U.S., Asians are over-represented among programmers
relative to their share of the population and that whites and especially blacks 
are under-represented. Should we impose racial quotas on questions
at conferences and call that "equal opportunity" as well?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26911] lib2to3/tests/pytree_idempotency.py does not run

2016-05-06 Thread Terry J. Reedy

Terry J. Reedy added the comment:

(Import errors are runtime errors, not compile errors.)

After 'import lib2to3.pgen2', 'pgen2' in the code would not be valid.  A 'from' 
import is needed instead.  I fixed the import for 3.5/6 (but not 2.7), but the 
file still does not run.

  File "F:\Python\dev\35\lib\lib2to3\tests\pytree_idempotency.py", line 27, in 
main
gr = driver.load_grammar("Grammar.txt")
 ,,,
FileNotFoundError: [Errno 2] No such file or directory: 'Grammar.txt'

After fixing this with

 def main():
-gr = driver.load_grammar("Grammar.txt")
+gfile = os.path.dirname(os.path.dirname(__file__)) + "/Grammar.txt"
+gr = driver.load_grammar(gfile)
 dr = driver.Driver(gr, convert=pytree.convert)
 
the file fails with

FileNotFoundError: [Errno 2] No such file or directory: 'example.py'

There is no 'example.py in lib2to3.  The closest is 
lib2to3/tests/data/fixers/parrot_example.py.  At this point, I leave it 
Benjamin to fix the file so it runs or delete it.

The file is not used anywhere since it is not part of the regular test suite 
(that would require the name to begin with 'test_').  It was meant to be run as 
a test by itself -- see the doc string.  Perhaps the completion of 2to3 and the 
test suite made it obsolete.

--
nosy: +terry.reedy
stage:  -> needs patch
title: lib2to3/tests/pytree_idempotency.py has a broken import -> 
lib2to3/tests/pytree_idempotency.py does not run
type: compile error -> behavior
versions: +Python 2.7, Python 3.6

___
Python tracker 

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



[issue26969] ascynio should provide a policy to address pass-loop-everywhere problem

2016-05-06 Thread Ilya Kulakov

Ilya Kulakov added the comment:

Yury, that would do it.

Guido, that's indeed might be an anti-pattern. But it looks like passing event 
loop around is just a worse version of it.

--

___
Python tracker 

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



Re: A fun python CLI program for all to enjoy!

2016-05-06 Thread MRAB

On 2016-05-06 20:10, DFS wrote:

getAddresses.py

Scrapes addresses from www.usdirectory.com and stores them in a SQLite
database, or writes them to text files for mailing labels, etc

Now, just by typing 'fast food Taco Bell  10 db all' you can find
out how many Taco Bells are within 10 miles of you, and store all the
addresses in your own address database.

No more convoluted Googling, or hitting the 'Next Page' button, or
fumbling with the Yellow Pages...

Note: the db structure is flat on purpose, and the .csv files aren't
quote delimited.

Put the program in its own directory.  It creates the SQLite database
there, and writes files there, too.

Reviews of code, bug reports, criticisms, suggestions for improvement,
etc are all welcome.


OK, you asked for it... :-)

1. It's shorter and clearer not to compare with True or False:

   if verbose:

   and:

   if not dupeRow:

2. You can print a blank line with an empty print statement:

   print

3. When looking for unique items, a set is a better choice than a list:

   addrCheck = set()

   def addrUnique(addr):
   if addr not in addrCheck:
   x = True
   addrCheck.add(addr)
   else:
   x = False
   return x

4. Try string formatting instead multiple concatenation:

   print "%s arguments" % argCnt

5. Strings have a .join method, and when you combine it with string slicing:

   keyw = "+".join(sys.argv[1 : argCnt - 5])

6. Another example of string formatting:

   search = "%s %s %s %s %s" % (keyw, cityzip, state, miles, addrWant)

7. It's recommended to use the 'with' statement when handling files:

   with open(webfile, "w") as f:
   if store == "csv":
   f.write("Name,Address,CityStateZip\n")

   If you don't want to use the 'with' statement, note that closing the 
file is:


   f.close()

   It needs the "()"!

8. When using SQL, you shouldn't try to insert the values yourself; you 
should use parametrised queries:


   cSQL = "DELETE FROM addresses WHERE datasrc = ? AND search = ?;"
   if verbose:
   print cSQL
   db.execute(cSQL, (datasrc, search))
   conn.commit()

It'll insert the values where the "?" are and will do any necessary 
quoting itself. (Actually, some drivers use "?", others use "%s", so if 
it doesn't work with one, try the other.)


The way you wrote it, it would fail if a value contained a "'". 
It's that kind of thing that leads to SQL injection attacks.


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


[issue26969] ascynio should provide a policy to address pass-loop-everywhere problem

2016-05-06 Thread Yury Selivanov

Yury Selivanov added the comment:

> Honestly I think it's pretty crazy and out there to have multiple event
loops in the same thread. That feels like an anti-pattern inspired by some
other event loop APIs (in other languages) that encourage this. But asyncio
was not designed for that.

I agree.

OTOH, if you're designing a library for asyncio, you want it to be as foolproof 
as possible, so many people simply pass an event loop everywhere.  It's 
especially annoying when you have a huge chunk of code that didn't need the 
loop, and then when something needs it you have to refactor everything or use 
"get_event_loop".

In terms of performance, I don't think this is gonna affect anything, it's just 
a couple of additional thread-local sets in the Loop.run method.

And we can design "get_running_loop" to raise a clear exception if no loop is 
currently running.

--

___
Python tracker 

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



[issue26906] format(object.__reduce__) fails intermittently

2016-05-06 Thread Guido van Rossum

Guido van Rossum added the comment:

Probably.

--

___
Python tracker 

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



[issue26969] ascynio should provide a policy to address pass-loop-everywhere problem

2016-05-06 Thread Guido van Rossum

Guido van Rossum added the comment:

Honestly I think it's pretty crazy and out there to have multiple event
loops in the same thread. That feels like an anti-pattern inspired by some
other event loop APIs (in other languages) that encourage this. But asyncio
was not designed for that.

--

___
Python tracker 

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



[issue26969] ascynio should provide a policy to address pass-loop-everywhere problem

2016-05-06 Thread Yury Selivanov

Yury Selivanov added the comment:

> Thread may have multiple event loops, but only one, explicitly associated, is 
> default. And it's not necessary one which is currently running.

Ah, I got it.  You know what, this actually is starting to make sense.

Guido, what do you think about this?  Essentially, (Ilya, feel free to correct 
me if I'm wrong), we can implement the following:

1. Add a new thread-local storage, say "_running_loop"

2. Add another method "asyncio.get_running_loop()"

3. Update some places in asyncio where we currently use "get_event_loop()", 
such as Future constructor, Task.current_task, etc.

This might actually solve an awkwardness of get_event_loop(), which when 
called, instantiates an event loop if it doesn't find one, which makes it 
difficult to know if an event loop was running before the call.

--

___
Python tracker 

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



[issue26939] android: test_functools hangs on armv7

2016-05-06 Thread Xavier de Gaye

Xavier de Gaye added the comment:

> Do you know in which precise test it hangs?

They are named in the first msg of each issue, the issues are:
issue #26938: android: test_concurrent_futures hangs on armv7
issue #26939: android: test_functools hangs on armv7
issue #26940: android: test_importlib hangs on armv7
issue #26941: android: test_threading hangs on armv7

The test_threading and test_importlib issues have also now a gdb backtrace, so 
we know not only the test name but also the full python frame stack with line 
numbers thanks to python-gdb.py magic. It seems that test_functools, 
test_threading and test_importlib all hang within take_gil().

test_concurrent_futures is different and hangs in a futex().

With "thread apply all backtrace",  nothing changes and gdb still prints:
Cannot access memory at address 0x0
#0  0xb6efae6c in ?? ()
#1  0xb6efd830 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

The problem seems to be that gdb does not have enough information to unwind the 
stack for the other threads and for thread #1 it only works after an 
interrupted continue command, and not on gdb startup.

--

___
Python tracker 

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



[issue26906] format(object.__reduce__) fails intermittently

2016-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There is one test 
(ClassPropertiesAndMethods.test_mutable_bases_with_failing_mro in test_descr) 
that crashes with the code from issue551412 because _PyType_Lookup() is 
recursive called from PyType_Ready(). Is this the reason? My patch prevents 
recursive calls.

Here is minimal example (for Python 3):

class M(type):
def mro(self):
hasattr(self, 'foo')
return type.mro(self)

class C(metaclass=M):
pass

When class C is created, C.mro() is called while C still is not ready. 
Resolving an attribute calls _PyType_Lookup() which calls PyType_Ready() which 
calls mro() etc.

--
keywords:  -patch

___
Python tracker 

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



[issue26969] ascynio should provide a policy to address pass-loop-everywhere problem

2016-05-06 Thread Ilya Kulakov

Ilya Kulakov added the comment:

> In this case I'm not sure how this is different from the current 
> "get_event_loop"

Thread may have multiple event loops, but only one, explicitly associated, is 
default. And it's not necessary one which is currently running.

I think what I propose here can be expressed in Python terms as an implicit 
context manager that replaces Thread's default event loop once while it "runs" 
particular event loop then switches it back (possible to None) once loop is 
stopped.

--

___
Python tracker 

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



[issue26969] ascynio should provide a policy to address pass-loop-everywhere problem

2016-05-06 Thread Yury Selivanov

Yury Selivanov added the comment:

To clarify: the problem lies in "return currently running event loop when 
called from within a coroutine" -- what if there is no GIL and we have a few 
event loops running?  You'd need to use a threadlocal storage.  In this case 
I'm not sure how this is different from the current "get_event_loop".

--

___
Python tracker 

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



[issue26969] ascynio should provide a policy to address pass-loop-everywhere problem

2016-05-06 Thread Yury Selivanov

Yury Selivanov added the comment:

> Probably it would make sense to modify behavior of the default policy to make 
> get_event_loop to return Thread-local event loop when called from 
> out-of-event-loop and return currently running event loop when called from 
> within a coroutine.

The problem with this approach is that you're relying on the presence of GIL.  
If, let's say, PyPy releases tomorrow with 3.5 and STM, this won't work.

--

___
Python tracker 

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



[issue26911] lib2to3/tests/pytree_idempotency.py has a broken import

2016-05-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 3279c910d0e0 by Terry Jan Reedy in branch '3.5':
Issue 26911: fix import (other problems remain).
https://hg.python.org/cpython/rev/3279c910d0e0

--
nosy: +python-dev

___
Python tracker 

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



[issue26969] ascynio should provide a policy to address pass-loop-everywhere problem

2016-05-06 Thread Ilya Kulakov

Ilya Kulakov added the comment:

> Why does it have to be a standard part of asyncio?

I've only seen few libraries that deal with asyncio so far (aiohttp, pyzmq), 
but my general impression is that this is a generic problem.

With asyncio code should be (ideally) written as a set of coroutines which 
schedule each other or are called in response to monitored events. That means 
(and asyncio very implementation shows that) loop has to be "self" for all 
coroutines it executes.

Thread-local default event loop is a good solution to get an entry point into 
the event loop from an out-of-event-loop execution location. But (ideally) 
there will be exactly one place in code where this behavior is convenient: when 
you "instantiate" and run event loop. After that the event loop becomes "self" 
for each coroutine it may run and therefore it's now convenient for 
get_event_loop to return currently running event loop.

Probably it would make sense to modify behavior of the default policy to make 
get_event_loop to return Thread-local event loop when called from 
out-of-event-loop and return currently running event loop when called from 
within a coroutine.

> Why don't you just use 'loop = asyncio.get_event_loop()' in places where you 
> need the loop?

As David pointed out, I'm not using thread-local event loop.

--

___
Python tracker 

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



[issue26889] Improve Doc/library/xmlrpc.client.rst

2016-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you for your review Terry. Updated patch addresses most of your comments. 
But I'm unable to expand ServerProxy description as you suggest. May you can do 
this? My purpose was modest. Just fix some incorrect and outdated sentences. 
Then I fixed some formatting. I was not going and is not able to do anything 
besides this. I will take all that you offer.

--
Added file: http://bugs.python.org/file42763/docs_xmlrpc_client_2.patch

___
Python tracker 

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



[issue26938] android: test_concurrent_futures hangs on armv7

2016-05-06 Thread Xavier de Gaye

Xavier de Gaye added the comment:

The strace output, the process is blocked in a futex system call:

root@generic:/ # strace -p 1304
Process 1304 attached
futex(0xb6f24880, FUTEX_WAIT_PRIVATE, 2, NULL

--

___
Python tracker 

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



[issue26906] format(object.__reduce__) fails intermittently

2016-05-06 Thread Guido van Rossum

Guido van Rossum added the comment:

But the problem isn't limited to format()... Why would format() be special?

--

___
Python tracker 

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



[issue26906] format(object.__reduce__) fails intermittently

2016-05-06 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Is there a way to have format() try to force the initialization, by explicitly 
doing the equivalent of obj.__format__, at least for types, instead of raising 
the TypeError?

--
nosy: +terry.reedy

___
Python tracker 

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



[issue26941] android: test_threading hangs on armv7

2016-05-06 Thread Xavier de Gaye

Xavier de Gaye added the comment:

Adding the back trace.

--
Added file: http://bugs.python.org/file42761/test_threading_gdb_bt.txt

___
Python tracker 

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



A fun python CLI program for all to enjoy!

2016-05-06 Thread DFS

getAddresses.py

Scrapes addresses from www.usdirectory.com and stores them in a SQLite 
database, or writes them to text files for mailing labels, etc


Now, just by typing 'fast food Taco Bell  10 db all' you can find 
out how many Taco Bells are within 10 miles of you, and store all the 
addresses in your own address database.


No more convoluted Googling, or hitting the 'Next Page' button, or 
fumbling with the Yellow Pages...


Note: the db structure is flat on purpose, and the .csv files aren't 
quote delimited.


Put the program in its own directory.  It creates the SQLite database 
there, and writes files there, too.


Reviews of code, bug reports, criticisms, suggestions for improvement, 
etc are all welcome.


Enjoy!




#getAddresses.py

import os, sys, requests, time, datetime
from lxml import html
import pyodbc, sqlite3, re


#show values of variables, HTML content, etc
#set it to False for short/concise program output
verbose = False
if verbose == True:
print "The verbose setting is turned On."
print ""


#check if address is unique
addrCheck = []
def addrUnique(addr):
if addr not in addrCheck:
x = True
addrCheck.append(addr)
else: x = False 
return x


#validate and parse command line
def showHelp():
print ""
	print " Enter search word(s), city or zip, state, miles to search, txt 
or csv or db, # addresses to save (no commas)"

print ""
print " eg: restaurant Knoxville TN 10 txt 50"
	print " search for restaurants within 10 miles of Knoxville TN, and 
write"

print " the first 50 address to a txt file"
print ""
print " eg: furniture 30303 GA 20 csv all"
print " search for furniture within 20 miles of zip 30303 GA,"
print " and write all results to a csv file"
print ""
print " eg: boxing gyms Detroit MI 10 db 5"
	print " search for boxing gyms within 10 miles of Detroit MI, and 
store"

print " the first 5 results in a database"
print ""
print " All entries are case-insensitive (ie TX or tx are acceptable)"
exit(0)

argCnt = len(sys.argv)
if argCnt < 7: showHelp()
if verbose == True:
print ""
print str(argCnt) + " arguments"

keyw = "" #eg restaurant, 
boxing gym
if argCnt == 7: keyw = sys.argv[1]  #one search word
if argCnt >  7:  #multiple search words
for i in range(1,argCnt-5):
keyw = keyw + sys.argv[i] + "+"
keyw = keyw[:-1]#drop trailing + sign
cityzip  = sys.argv[argCnt-5]   #eg Atlanta or 30339
state= sys.argv[argCnt-4]   #eg GA
miles= sys.argv[argCnt-3]   #eg 5,10,20,30,50 (website allows max 30)
store= sys.argv[argCnt-2]   #write address to file or database
addrWant = sys.argv[argCnt-1]   #eg save All or number >0

if addrWant.lower() != "all": #how many addresses to save
if addrWant.isdigit() == False: showHelp()
if addrWant == "0": showHelp()
addrWant = int(addrWant)
elif addrWant.lower() == "all": addrWant = addrWant.lower()
else: addrWant = int(addrWant)

if store != "csv" and store != "txt" and store != "db": showHelp()


#begin timing the code
startTime = time.clock()


#website, SQLite db, search string, current date/time for use with db
datasrc = "www.usdirectory.com"
dbName  = "addresses.sqlite"
search  = keyw + " " + str(cityzip) + " " + state + " " + str(miles) + " 
" + str(addrWant)

loaddt = datetime.datetime.now()


#write addresses to file
#each time the same search is done, the file is deleted and recreated
if store == "csv" or store == "txt":
#csv will write in .csv format - header and 1 line per address
#txt will write out 3 lines per address, then blank before next address
webfile  = "usdirectory.com_"+keyw+"_"+cityzip+"_"+state+"."+store
f = open(webfile,"w")
if store == "csv": f.write("Name,Address,CityStateZip\n")
f.close


#store addresses in database
cSQL = ""
if store == "db": 
#creates a SQLite database that Access 2003 can't read
#conn = sqlite3.connect(dbName)

#also creates a SQLite database that Access 2003 can't read
conn = pyodbc.connect('Driver={SQLite3 ODBC Driver};Database=' + dbName)
db   = conn.cursor()

cSQL =  "CREATE TABLE If Not Exists ADDRESSES "
	cSQL += "(datasrc, search, category, name, street, city, state, zip, 
loaddt, "

cSQL += "PRIMARY KEY (datasrc, search, name, street));"
db.execute(cSQL)

# cSQL =  "CREATE TABLE If Not Exists CATEGORIES "
# cSQL += "(catID INTEGER PRIMARY KEY, catDesc);"
# db.execute(cSQL)
	# db.execute("CREATE UNIQUE INDEX If Not Exists UIDX_CATDESC ON 

[issue26903] ProcessPoolExecutor(max_workers=64) crashes on Windows

2016-05-06 Thread Terry J. Reedy

Terry J. Reedy added the comment:

The example runs fine, in about 1 second, on my 6 core (which I guess is 12 
logical cores) Pentium.  I am guessing that the default number of workers needs 
to be changed, at least on Windows, to min(#logical_cores, 60)

--
nosy: +bquinlan, terry.reedy

___
Python tracker 

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



[issue26889] Improve Doc/library/xmlrpc.client.rst

2016-05-06 Thread Terry J. Reedy

Terry J. Reedy added the comment:

This is my first reading of this doc.  The formatting improvements look good.  
A definite enhancement.

Review contains a few comments.  My main difficulty is separating creation of a 
proxy instance from use of a proxy instance.  Some of the creation parameters 
govern the use, and hence do not make must sense until one reads the instance 
description a few paragraphs further on.  
Perhaps the initial sentence "A :class:`ServerProxy` instance is an object that 
manages communication with aremote XML-RPC server." should be expanded into a 
paragraph with some of the description given later.

--
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: After a year using Node.js, the prodigal son returns

2016-05-06 Thread Rustom Mody
On Friday, May 6, 2016 at 8:23:27 AM UTC+5:30, Chris Angelico wrote:
> On Fri, May 6, 2016 at 12:49 PM, Michael Torrie  wrote:
> > On 05/04/2016 02:59 AM, Steven D'Aprano wrote
> >> A year ago, Gavin Vickery decided to move away from Python and give
> >> Javascript with Node.js a try. Twelve months later, he has written about 
> >> his
> >> experiences:
> >>
> >>
> >> http://geekforbrains.com/post/after-a-year-of-nodejs-in-production
> >
> > Very interesting.  Frankly Javascript sounds awful.  Even on the front end.
> 
> https://www.destroyallsoftware.com/talks/the-birth-and-death-of-javascript
> 
> JavaScript is terrible. Really, really bad. And because of that, it
> has the potential to sweep the world.

If python community is passionate in hating javascript it may wish to look at
webassembly:
https://en.wikipedia.org/wiki/WebAssembly
https://medium.com/javascript-scene/what-is-webassembly-the-dawn-of-a-new-era-61256ec5a8f6
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26163] FAIL: test_hash_effectiveness (test.test_set.TestFrozenSet)

2016-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I can stably reproduce this. 

PYTHONHASHSEED=36 ./python -m test.regrtest -vm test_hash_effectiveness test_set

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue26967] argparse: allow_abbrev=False stops -vv from working

2016-05-06 Thread Xiang Zhang

Xiang Zhang added the comment:

I agree with you. But right now, it seems parsing short options and 
allow_abbrev both rely on the same logic. If you turn off allow_abbrev, short 
options parsing also disabled. Separating them seems nontrivial.

--

___
Python tracker 

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



[issue26939] android: test_functools hangs on armv7

2016-05-06 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> Still hangs at test_lru_cache_threaded with this last patch :(

What about the other tests (test_importlib, test_threading)?

Do you know in which precise test it hangs? (use "-v" to print test names)

> There are two threads, gdb does not print the backtrace of the other thread.

Even with "thread apply all backtrace" (Google tells me this is the 
incantation)?

--

___
Python tracker 

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



[issue26969] ascynio should provide a policy to address pass-loop-everywhere problem

2016-05-06 Thread R. David Murray

R. David Murray added the comment:

Because, as indicated by the OP, I'm not using the default event loop of the 
thread.

Thinking about my code, I now remember that the reason I went down this path 
was because I wanted to make sure that my functions, like asyncio functions, 
accepted the optional loop parameter, and that it worked. For it to work my 
code pretty much has to pass loop everywhere, because that was a design 
decision I made early on.  So maybe there's nothing interesting for me here 
after all.

--

___
Python tracker 

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



[issue26632] __all__ decorator

2016-05-06 Thread R. David Murray

R. David Murray added the comment:

"This will cause more problems than it solves" and "this looks unpythonic" are, 
IMO, not strong arguments against it without butressing discussion.  If we can 
have some examples of problems it will cause, or a concrete explanation of wy 
something that makes code easier to understand and update (by putting the 
__all__ declaration next to the object being made public) is unpythonic, that 
would also help.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue26969] ascynio should provide a policy to address pass-loop-everywhere problem

2016-05-06 Thread Yury Selivanov

Yury Selivanov added the comment:

> Currently if one needs lazily resolve event loop depending on where awaitable 
> is being awaited have to pass loop everywhere explicitly. That quickly 
> becomes an unnecessary noise in interfaces of callables. 

Why don't you just use 'loop = asyncio.get_event_loop()' in places where you 
need the loop?

--

___
Python tracker 

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



[issue26969] ascynio should provide a policy to address pass-loop-everywhere problem

2016-05-06 Thread R. David Murray

R. David Murray added the comment:

Can we at least make it part of the documentation?  It's not obvious to me, at 
least, how to do it.  (Maybe I just haven't thought about it carefully enough.) 
 For that matter, it wasn't obvious to me it could even be done, so I've been 
passing loop everywhere in my code rather than thinking about how to avoid it; 
which is another argument for documenting it at least.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue11063] uuid.py module import has heavy side effects

2016-05-06 Thread Michael Felt

Michael Felt added the comment:

I cannot comment on uuid directly, but for me, this is yet another example of 
how assumptions can break things.

imho - if you know the exact version of s shared library that you want, calling 
cdll directly should be find. Maybe find_library is historic.

However, an advantage to calling find_library is that it should lead to an 
OSError if it cannot be loaded. But trapping OSError on a call to ctypes.cdll 
or testing for None (NULL) from find_library() is the option of a developer 
using the ctypes interface.

As far as libFOO.so.N - do you always want to assume it is going to be version 
N, or are you expecting to be able to work work version N+X?
Again, find_library() can give you the library name it would load - but a 
programmer must be aware of the platform differences (e.g., AIX returns not a 
filename, but a libFOO.a(libFOO.so.N) - as just one example.
p.s. as far as ldconfig being part of the problem on AIX (as it does not exist 
and can lead to OSError or just long delays, I have worked out a (pending) 
patch for ctypes/util (and ctypes/cdll) that may address the issues with uuid 
import on AIX. (see issue26439 for the patch)

--
nosy: +Michael.Felt

___
Python tracker 

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



[issue26632] __all__ decorator

2016-05-06 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

Updated.

--
Added file: http://bugs.python.org/file42760/26632-in-c-3.diff

___
Python tracker 

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



[issue18726] json functions have too many positional parameters

2016-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

My remark was just about that I proposed to start a deprecation period at the 
time of developing Python 3.4. If this did accepted, the deprecation period 
would already finished and we would come up to the same code in 3.6.

It doesn't matter now.

--

___
Python tracker 

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



[issue26939] android: test_functools hangs on armv7

2016-05-06 Thread Xavier de Gaye

Xavier de Gaye added the comment:

The strace of test_lru_cache_threaded:

...
gettimeofday({1462553238, 580860}, NULL) = 0
clock_gettime(CLOCK_REALTIME, {1462553238, 581276772}) = 0
gettimeofday({1462553238, 581672}, NULL) = 0
clock_gettime(CLOCK_REALTIME, {1462553238, 582078767}) = 0
gettimeofday({1462553238, 583956}, NULL) = 0
clock_gettime(CLOCK_REALTIME, {1462553238, 585865959}) = 0
gettimeofday({1462553238, 587597}, NULL) = 0
clock_gettime(CLOCK_REALTIME, {1462553238, 589381724}) = 0
gettimeofday({1462553238, 589973}, NULL) = 0
clock_gettime(CLOCK_REALTIME, {1462553238, 591858839}) = 0
gettimeofday({1462553238, 593003}, NULL) = 0
clock_gettime(CLOCK_REALTIME, {1462553238, 593452750}) = 0
gettimeofday({1462553238, 593886}, NULL) = 0
clock_gettime(CLOCK_REALTIME, {1462553238, 594364345}) = 0
gettimeofday({1462553238, 594764}, NULL) = 0
clock_gettime(CLOCK_REALTIME, {1462553238, 595227771}) = 0
gettimeofday({1462553238, 595626}, NULL) = 0
clock_gettime(CLOCK_REALTIME, {1462553238, 596027590}) = 0
gettimeofday({1462553238, 596448}, NULL) = 0
clock_gettime(CLOCK_REALTIME, {1462553238, 596848736}) = 0
gettimeofday({1462553238, 597259}, NULL) = 0
clock_gettime(CLOCK_REALTIME, {1462553238, 597665484}) = 0
gettimeofday({1462553238, 598060}, NULL) = 0
clock_gettime(CLOCK_REALTIME, {1462553238, 598869963}) = 0
gettimeofday({1462553238, 599547}, NULL) = 0
clock_gettime(CLOCK_REALTIME, {1462553238, 601053152}) = 0
gettimeofday({1462553238, 601593}, NULL) = 0
clock_gettime(CLOCK_REALTIME, ^CProcess 908 detached
 

--

___
Python tracker 

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



[issue18531] Undocumented different between METH_KEYWORDS and **kws

2016-05-06 Thread Eric V. Smith

Eric V. Smith added the comment:

Okay. Adding back 3.5 and 2.7, in case someone wants to document the behavior 
there. I'm not sure if we fix docs in 3.4 still.

--
versions: +Python 2.7, Python 3.5

___
Python tracker 

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



[issue18726] json functions have too many positional parameters

2016-05-06 Thread Guido van Rossum

Guido van Rossum added the comment:

> Guido's decision on similar issue25628 is that changing keyword-or-positional 
> parameters to keyword-only is safe and can be made without deprecation.

> If we started the deprecation period in 3.4, we could finish it in 3.6.

That makes little sense. You can't start deprecation in 3.4 or in 3.5 since 
these have been released already.

But what I said implies that you can make these things mandatory in 3.6 without 
having to worry about deprecating them, so the start of the deprecation period 
is meaningless.

However I do encourage you to be conservative, and add a warning about this and 
similar cases when the alphas and betas go out; and if you get much pushback 
during beta consider changing your mind.

--

___
Python tracker 

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



[issue26156] Bad name into power operator syntax

2016-05-06 Thread Guido Treutwein

Guido Treutwein added the comment:

I'm with David here, in that a change would improve ease of comprehension:
I still find it strange, that the grammar symbol has the same name as the
keyword (or in the proposed version keyword+'expr'), which is never done on
more widely used levels. I would have expected something like
'coroutine_suspension', which reflects what it is and not which keyword is
required to state it.

2016-05-06 15:04 GMT+02:00 R. David Murray :

>
> R. David Murray added the comment:
>
> Sounds like it is a bit more than just confusion: given that power can be
> used outside a coroutine but await can't, Serhiy's formulation would seem
> to me to be more semantically correct, even if syntactically it is the same
> as the current.
>
> I think it would regardless be better to replace 'await' with
> 'await_expr', so +1 on that from me as well.
>
> --
> nosy: +r.david.murray
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue18726] json functions have too many positional parameters

2016-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Guido's decision on similar issue25628 is that changing keyword-or-positional 
parameters to keyword-only is safe and can be made without deprecation.

If we started the deprecation period in 3.4, we could finish it in 3.6.

Proposed simple patch changes all optional parameters in functions and 
constructors that takes too much parameters in the json module to keyword-only 
without deprecation.

--
keywords: +patch
nosy: +gvanrossum
stage:  -> patch review
versions: +Python 3.6 -Python 3.4
Added file: http://bugs.python.org/file42759/json_keyword_only.patch

___
Python tracker 

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



[issue26906] format(object.__reduce__) fails intermittently

2016-05-06 Thread Guido van Rossum

Guido van Rossum added the comment:

Sadly it's been a very long time since I wrote that code and I don't recall
much about it. I presume there was a good reason for not to do it in
_PyType_Lookup(), but who knows -- maybe the oroginal approach was just too
naive and nobody cared? I'm not excited by a patch that does this for 38
types -- invariably there will be another type that still surfaces the same
bug.

--

___
Python tracker 

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



Re: Slight problems with python in Windows

2016-05-06 Thread Zachary Ware
Hi Peter,

On Fri, May 6, 2016 at 6:22 AM, Peter Toye  wrote:
> I'm trying to install Python under Windows 7 so that I can use git-review and 
> have found a few niggling issues.
>
> 1) Apparently (according to the git-review pages) pip has a problem with 
> directories with spaces in their names. Python's default installation 
> directory is under Program Files. I agree that this is a pip issue rather 
> than a Python one, but maybe a warning message would help?

I don't believe this is true anymore, I've successfully used pip with
3.5 installed in Program Files, and also just now in a test venv named
"test venv".  Do note that with installation in Program Files, you get
the benefits of the install directory being writable only to
administrators, but also the drawbacks: only administrators can use
pip to install to the global site-packages.  You can use either 'pip
--user', or create a venv in a directory writable to you and use it.
Also note that you can't use "pip.exe" to upgrade pip itself since it
can't overwrite "pip.exe" while it's in use; use 'python -m pip'
instead.

> 2) According to the Programs and Files section of the Windows Control Panel, 
> installing Python also installs something called the Python Launcher. When I 
> try to remove this (so I can reinstall Python in a better directory) is comes 
> up with an error message:

The Python Launcher is a very handy tool called 'py.exe' which makes
it much easier to use more than one version of Python on a Windows
machine.  In an all users install, py.exe is installed to C:\Windows
and is thus always available on PATH, so you can invoke Python 3.5 by
calling 'py -3.5' without having to adjust your PATH.  The error
message is odd, though, would you mind trying to reproduce it and
opening a bug at bugs.python.org?

> Error opening installation log file.  Verify that the specified log file 
> location exists and is writable.
>
> After reinstalling I now have 2 copies of the launcher I hope it doesn't 
> give me any problems.

It shouldn't.  The launcher only installs 2 files, py.exe and pyw.exe
(counterpart to pythonw.exe), both in C:\Windows.

> 3) After uninstalling Python the installation directory is still there with a 
> few files in it (possibly connected with the previous issue). Can I just 
> delete it?

Yes, that should be fine.  I would guess it's still there due to pip
artifacts in Lib\ and Scripts\.

Hope this helps,
-- 
Zach
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Slight problems with python in Windows

2016-05-06 Thread Pertti Kosunen

On 6.5.2016 14:22, Peter Toye wrote:

I'm trying to install Python under Windows 7 so that I can use git-review and 
have found a few niggling issues.

1) Apparently (according to the git-review pages) pip has a problem with 
directories with spaces in their names. Python's default installation directory 
is under Program Files. I agree that this is a pip issue rather than a Python 
one, but maybe a warning message would help?


Select install to all users and it should install to root \PythonXY 
directory where XY is major version number.

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


[issue25628] Make namedtuple "verbose" and "rename" parameters into keyword only arguments

2016-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Then namedtuple_keywords.diff LGTM. But please document changes.

--
assignee:  -> rhettinger
stage: patch review -> commit review

___
Python tracker 

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



[issue26939] android: test_functools hangs on armv7

2016-05-06 Thread Xavier de Gaye

Xavier de Gaye added the comment:

> Can you post the backtraces of all threads (at least the innermost frames)?

There are two threads, gdb does not print the backtrace of the other thread. My 
current gdb setup with a connection to a gdb-server misses some stuff (access 
to the loader or some libraries I guess) and needs to be completed with the 
same setup as the one used by the ndk-gdb script (released by google for 
android applications).

> Also, can you reproduce on an actual armv7 machine? Just wondering if there 
> may be something peculiar in the emulator.

I don't have an armv7 device that can be used for testing.

--

___
Python tracker 

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



[issue26632] __all__ decorator

2016-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Added a couple of comments on Rietveld.

But sorry, the overall idea looks unpythonic to me. I'm strong -1.

--

___
Python tracker 

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



[issue25628] Make namedtuple "verbose" and "rename" parameters into keyword only arguments

2016-05-06 Thread Guido van Rossum

Guido van Rossum added the comment:

I think such a change can be safely made in a feature release (say 3.6) without 
further deprecation. But not in a bugfix release (say 3.5.2).

--

___
Python tracker 

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



Re: Whittle it on down

2016-05-06 Thread Peter Otten
DFS wrote:

> There are up to 4 levels of categorization:
 
> http://www.usdirectory.com/cat/g0 shows 21 Level 1 categories, and 390
> Level 2.  To get the Level 3 and 4 you have to drill-down using the
> hyperlinks.
> 
> How to do it in python code is beyond my skills at this point.  Get the
> hrefs and load them and parse, then get the next level and load them and
> parse, etc.?

Yes, that should work ;)

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


[issue25628] Make namedtuple "verbose" and "rename" parameters into keyword only arguments

2016-05-06 Thread Guido van Rossum

Guido van Rossum added the comment:

And by "safely" I mean that I don't mind if some code breaks when they upgrade 
to a new feature release.

FWIW the code most likely to break is code that wraps these functions with an 
identical interface.

--

___
Python tracker 

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



[issue18531] Undocumented different between METH_KEYWORDS and **kws

2016-05-06 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

On May 06, 2016, at 03:41 PM, Eric V. Smith wrote:

>I agree it would be a 3.6 only change (and I've change the versions to
>reflect that).

The reason the other versions were included was because this was originally
reported as a documentation bug.  It should probably still be documented in
those older releases.

--

___
Python tracker 

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



[issue26969] ascynio should provide a policy to address pass-loop-everywhere problem

2016-05-06 Thread Guido van Rossum

Guido van Rossum added the comment:

Can't you easily write such a policy yourself? Why does it have to be a
standard part of asyncio?

--

___
Python tracker 

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



[issue18531] Undocumented different between METH_KEYWORDS and **kws

2016-05-06 Thread Eric V. Smith

Eric V. Smith added the comment:

I think it's okay to change this as far as str.format() goes.

Interestingly enough, the motivating case to add str.format_map() in issue 6081 
was exactly this kind of code. Although I notice that the example in that 
issue, which it shows as failing, works in both 2.7 and 3.4 (the only versions 
I have handy). So I'm not sure what changed after 2009 to cause that code to 
start working, but I'd be okay with it breaking again. But maybe we should 
track it down, in case it was deliberately changed and is important to someone.

In any event, since str.format_map() is well-known (to me, at least!), and is 
the approved way of getting the behavior of passing a specific map in to the 
format machinery, I'm okay with changing **dict to create an exact new dict, at 
least as far as str.format() goes. I can't speak to the overall implications 
(such as other APIs and performance).

I agree it would be a 3.6 only change (and I've change the versions to reflect 
that).

--
versions:  -Python 2.7, Python 3.5

___
Python tracker 

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



[issue26939] android: test_functools hangs on armv7

2016-05-06 Thread Xavier de Gaye

Xavier de Gaye added the comment:

Still hangs at test_lru_cache_threaded with this last patch :(

--

___
Python tracker 

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



[issue26632] __all__ decorator

2016-05-06 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

I think I missed a decref.  New diff.

--
Added file: http://bugs.python.org/file42758/26632-in-c-2.diff

___
Python tracker 

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



Re: python - handling HTTP requests asynchronously

2016-05-06 Thread justin walters
On Thu, May 5, 2016 at 11:56 PM,  wrote:

> Hi everyone,
> I need to generate a PDF report for each entry of a django queryset.
> There'll be between between 30k and 40k entries.
>
> The PDF is generated through an external API. Since currently is generated
> on demand, this is handled synchronously via an HTTP request/response. That
> will be different for this task, since I think I'll use a django management
> command to loop through the queryset and perform the PDF generation.
>
> Which approach should I follow for this task? I thought about 3 possibile
> solutions, although are technologies that I never used:
>
> 1) Celery: assign a task (http request with a different payload) to a
> worker, then retrieve it once it's done.
>
> 2) request-futures: using requests in a non-blocking way.
>
> 3) multiprocessing module, with e.g. 10 as workers limit.
>
>
> the goal is to use the API concurrently (e.g. send 10 or 100 http requests
> simultaneously, depending on how many concurrent requests the API can
> handle).
>
> Anybody here that handled a similar task and can give advices on how to
> proceed on this?
> --
> https://mail.python.org/mailman/listinfo/python-list
>



Have you tried channels: https://github.com/andrewgodwin/channels ? If it's
an asyncronous request/response cycle you're looking for, it should work
well. Essentially, you have worker processes that receive a message over a
websocket connection and then send the new message back to the "group". I
would recommend using the redis in memory transaction layer if you go this
route as it is the fastest and most efficient. The best part about channels
is that you can still run a normal django app alongside it. You can have
only one app use websockets while the rest use standard http..
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue18531] Undocumented different between METH_KEYWORDS and **kws

2016-05-06 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

Eric should chime in on the str.format() implications.

--

___
Python tracker 

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



[issue18531] Undocumented different between METH_KEYWORDS and **kws

2016-05-06 Thread Barry A. Warsaw

Changes by Barry A. Warsaw :


--
nosy: +eric.smith

___
Python tracker 

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



[issue1528167] Tweak to make string.Templates more customizable

2016-05-06 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

Agreed with Serhiy.  Raymond's approach is nicer, but I'm still not convinced 
about the use case.  Closing.

If someone wants to run with this again, an updated patch would be needed, and 
the issue could be reopened, but I also suggest following through with 
Raymond's idea.

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

___
Python tracker 

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



[issue26632] __all__ decorator

2016-05-06 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

Here's a C implementation.  I'm a bit under the weather so please do double 
check my refcounting logic. ;)

No tests or docs yet, but those would be easy to add.  Here's an example:

@public
class Foo:
pass

public(qux=3)

print(qux)

@public
def zzz():
pass

public(jix=1, jox=2, jrx=3)

print(__all__)
print(jix, jox, jrx)

You could also try to add an explicit __all__ in the module and those names 
will get appended to it.

--
keywords: +patch
Added file: http://bugs.python.org/file42757/26632-in-c.diff

___
Python tracker 

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



[issue26939] android: test_functools hangs on armv7

2016-05-06 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Oops, sorry, hadn't seen the patch didn't compile. Can you tried with this new 
patch? (atomic_explicit2.patch)

--
Added file: http://bugs.python.org/file42756/atomic_explicit2.patch

___
Python tracker 

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



[issue26967] argparse: allow_abbrev=False stops -vv from working

2016-05-06 Thread Michael Kruse

Michael Kruse added the comment:

I think the allow_abbrev option should be orthogonal on how short options are 
parsed. I am using parse_known_args() to forward the unrecognized args to 
another program, therefore allow_abbrev=False is essential.

There is a special handling for short options in the consume_optional and 
_get_option_tuples to allow them being concatenated with one dash, as commonly 
done with short options (eg. "tar -czf file"). I interpret allow_abbrev as an 
option to avoid matching non-exiting options that should be forwarded to the 
other program; '-vv' is an existing option with the same meaning as '-v -v'.

This would also mean that parse_known_args(['-vz']) (where '-v' is a registered 
argument, but '-z' is not) matches '-v' and returns '-z' as unknown argument; 
but I don't know whether you want to go that far. It is difficult to interpret 
whether '-verify' should mean '-v -e -r -i -f -y' or '--verify' (but this is 
why there are double-dash options), especially when the first letter is not a 
registered short option.

--

___
Python tracker 

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



[issue26939] android: test_functools hangs on armv7

2016-05-06 Thread Xavier de Gaye

Xavier de Gaye added the comment:

Android has stdatomic.h and HAVE_STD_ATOMIC is defined.

The build fails with the patch, see the errors in the attached file. This is 
the native compilation of python, the patches in my build system are also 
applied to the native build so that they can be checked. I can prevent that if 
needed.

--
Added file: http://bugs.python.org/file42755/build-failure.txt

___
Python tracker 

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



Re: python, ctypes and GetIconInfo issue

2016-05-06 Thread mymyxin
A further question if you don't mind.

In your example you used a base class
and ICONINFO well as ICONINFOEX inherit it.
As the members of ICONINFO are part of ICONINFOEX
couldn't we do something like

class ICONINFO_BASE(ctypes.Structure): 
def __del__(self, ): 
if self.hbmMask: 
gdi32.DeleteObject(self.hbmMask) 
self.hbmMask = None 
if self.hbmColor: 
gdi32.DeleteObject(self.hbmColor) 
self.hbmColor = None 

class ICONINFO(ICONINFO_BASE): 
_fields_ = (('fIcon',wintypes.BOOL), 
('xHotspot', wintypes.DWORD), 
('yHotspot', wintypes.DWORD), 
('hbmMask',  wintypes.HBITMAP), 
('hbmColor', wintypes.HBITMAP)) 

class ICONINFOEX(ICONINFO): 
_fields_ = (('cbSize',wintypes.DWORD), 
# ('fIcon', wintypes.BOOL), 
# ('xHotspot',  wintypes.DWORD), 
# ('yHotspot',  wintypes.DWORD), 
# ('hbmMask',   wintypes.HBITMAP), 
# ('hbmColor',  wintypes.HBITMAP), 
('wResID',wintypes.WORD), 
('szModName', wintypes.WCHAR * MAX_PATH), 
('szResName', wintypes.WCHAR * MAX_PATH)) 

def __init__(self, *args, **kwds): 
super(ICONINFOEX, self).__init__(*args, **kwds) 
self.cbSize = ctypes.sizeof(self)

A dir on instance of that class indicates that it should be possible
as it contains all needed members and size seems to be correct as well,
but a call to GetIconInfoExW fails with:

WindowsError: [Error 87] The parameter is incorrect. 


info = ICONINFOEX()
info.cbSize = ctypes.sizeof(info) 
print dir(info)
print info.cbSize
user32.GetIconInfoExW(hIcon, ctypes.byref(info)) 

Thank you
Hubert
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Whittle it on down

2016-05-06 Thread DFS

On 5/6/2016 9:58 AM, DFS wrote:

On 5/6/2016 3:45 AM, Peter Otten wrote:

DFS wrote:



Should've looked earlier.  Their master list of categories
http://www.usdirectory.com/cat/g0 shows a few commas, a bunch of dashes,
and the ampersands we talked about.

"OFFICE SERVICES, SUPPLIES & EQUIPMENT" gets removed because of the
comma.

"AUTOMOBILE - DEALERS" gets removed because of the dash.

I updated your regex and it seems to have fixed it.

orig: (r"^[A-Z\s&]+$")
new : (r"^[A-Z\s&,-]+$")


Thanks again.


If there is a "master list" compare your candidates against it instead of
using a heuristic, i. e.

categories = set(master_list)
output = [category for category in input if category in categories]

You can find the categories with


import urllib.request
import bs4
soup =

bs4.BeautifulSoup(urllib.request.urlopen("http://www.usdirectory.com/cat/g0;).read())


categories = set()
for li in soup.find_all("li"):

... assert li.parent.parent["class"][0].startswith("category_items")
... categories.add(li.text)
...

print("\n".join(sorted(categories)[:10]))




"import urllib.request
ImportError: No module named request"



Figured it out using urllib2.  Your code returns 411 categories from 
that first page.


There are up to 4 levels of categorization:


Level 1: Arts & Entertainment
Level 2:   Newspapers

Level 3: Newspaper Brokers
Level 3: Newspaper Dealers Back Number
Level 3: Newspaper Delivery
Level 3: Newspaper Distributors
Level 3: Newsracks
Level 3: Printers Newspapers
Level 3: Newspaper Dealers

Level 3: News Dealers
Level 4:   News Dealers Wholesale
Level 4:   Shoppers News Publications

Level 3: News Service
Level 4:   Newspaper Feature Syndicates
Level 4:   Prepress Services




http://www.usdirectory.com/cat/g0 shows 21 Level 1 categories, and 390 
Level 2.  To get the Level 3 and 4 you have to drill-down using the 
hyperlinks.


How to do it in python code is beyond my skills at this point.  Get the 
hrefs and load them and parse, then get the next level and load them and 
parse, etc.?





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


Slight problems with python in Windows

2016-05-06 Thread Peter Toye
I'm trying to install Python under Windows 7 so that I can use git-review and 
have found a few niggling issues.

1) Apparently (according to the git-review pages) pip has a problem with 
directories with spaces in their names. Python's default installation directory 
is under Program Files. I agree that this is a pip issue rather than a Python 
one, but maybe a warning message would help?

2) According to the Programs and Files section of the Windows Control Panel, 
installing Python also installs something called the Python Launcher. When I 
try to remove this (so I can reinstall Python in a better directory) is comes 
up with an error message: 

Error opening installation log file.  Verify that the specified log file 
location exists and is writable.

After reinstalling I now have 2 copies of the launcher I hope it doesn't 
give me any problems.

3) After uninstalling Python the installation directory is still there with a 
few files in it (possibly connected with the previous issue). Can I just delete 
it?
 
Regards,

Peter
mailto:pyt...@ptoye.com
www.ptoye.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Whittle it on down

2016-05-06 Thread DFS

On 5/6/2016 3:45 AM, Peter Otten wrote:

DFS wrote:



Should've looked earlier.  Their master list of categories
http://www.usdirectory.com/cat/g0 shows a few commas, a bunch of dashes,
and the ampersands we talked about.

"OFFICE SERVICES, SUPPLIES & EQUIPMENT" gets removed because of the comma.

"AUTOMOBILE - DEALERS" gets removed because of the dash.

I updated your regex and it seems to have fixed it.

orig: (r"^[A-Z\s&]+$")
new : (r"^[A-Z\s&,-]+$")


Thanks again.


If there is a "master list" compare your candidates against it instead of
using a heuristic, i. e.

categories = set(master_list)
output = [category for category in input if category in categories]

You can find the categories with


import urllib.request
import bs4
soup =

bs4.BeautifulSoup(urllib.request.urlopen("http://www.usdirectory.com/cat/g0;).read())

categories = set()
for li in soup.find_all("li"):

... assert li.parent.parent["class"][0].startswith("category_items")
... categories.add(li.text)
...

print("\n".join(sorted(categories)[:10]))




"import urllib.request
ImportError: No module named request"


I'm on python 2.7.11






Accounting & Bookkeeping Services
Adoption Services
Adult Entertainment
Advertising
Agricultural Equipment & Supplies
Agricultural Production
Agricultural Services
Aids Resources
Aircraft Charters & Rentals
Aircraft Dealers & Services





Yeah, I actually did something like that last night.  Was trying to get
their full tree structure, which goes 4 levels deep: ie

Arts & Entertainment
  Newpapers
   News Dealers
Prepess Services


What I referred to as their 'master list' is actually just 2 levels 
deep.  My bad.


So far I haven't come across one that had anything in it but letters, 
dashes, commas or ampersands.


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


Re: After a year using Node.js, the prodigal son returns

2016-05-06 Thread Chris Angelico
On Fri, May 6, 2016 at 11:45 PM, Grant Edwards
 wrote:
>> JavaScript is terrible. Really, really bad. And because of that, it
>> has the potential to sweep the world.
>
> If your reasoning is correct, it'll never be able to overtake PHP.
>
> I've never written anything over a hundred or two lines in JavaScript,
> but for small stuff it seems OK -- though as others have noted there
> are some oddly missing batteries that result in use of a lot of small
> external libraries for things that any C, PHP, or Python user would
> have expected to be in the standard library.

Except that it's pretty easy to switch out PHP for Python, or anything
else. JavaScript is what it is because it's hard to just use a
different language.

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


Re: After a year using Node.js, the prodigal son returns

2016-05-06 Thread Grant Edwards
On 2016-05-06, Chris Angelico  wrote:
> On Fri, May 6, 2016 at 12:49 PM, Michael Torrie  wrote:
>> On 05/04/2016 02:59 AM, Steven D'Aprano wrote:
>>> A year ago, Gavin Vickery decided to move away from Python and give
>>> Javascript with Node.js a try. Twelve months later, he has written about his
>>> experiences:
>>>
>>>
>>> http://geekforbrains.com/post/after-a-year-of-nodejs-in-production
>>
>> Very interesting.  Frankly Javascript sounds awful.  Even on the front end.
>
> https://www.destroyallsoftware.com/talks/the-birth-and-death-of-javascript
>
> JavaScript is terrible. Really, really bad. And because of that, it
> has the potential to sweep the world.

If your reasoning is correct, it'll never be able to overtake PHP.

I've never written anything over a hundred or two lines in JavaScript,
but for small stuff it seems OK -- though as others have noted there
are some oddly missing batteries that result in use of a lot of small
external libraries for things that any C, PHP, or Python user would
have expected to be in the standard library.

-- 
Grant Edwards   grant.b.edwardsYow! I'm wearing PAMPERS!!
  at   
  gmail.com

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


Re: python, ctypes and GetIconInfo issue

2016-05-06 Thread mymyxin
Hello eryk sun,
first of all thank you very much, really appreciate your help.
Please be informed that I'm a python beginner, so forgive me if
my following questions sound stupid (also I'm not a native speaker).

> Please avoid windll. It caches the loaded library, which in turn 
> caches function pointers. So all packages that use windll.user32 are 
> potentially stepping on each others' toes with mutually incompatible 
> function prototypes. It also doesn't allow configuring 
> use_last_error=True to enable ctypes.get_last_error() for WinAPI 
> function calls. 
I assume you are referring to this block of code

GetIconInfo = windll.user32.GetIconInfo
GetIconInfo.argtypes   = [HICON, POINTER(ICONINFO)]
GetIconInfo.restype= BOOL
GetIconInfo.errcheck   = ErrorIfZero

where as you use

user32 = ctypes.WinDLL('user32', use_last_error=True) 
user32.GetIconInfoExW.errcheck = check_bool 
user32.GetIconInfoExW.restype = wintypes.BOOL 
user32.GetIconInfoExW.argtypes = ( 
wintypes.HICON, # _In_  hIcon 
PICONINFOEX,)   # _Out_ piconinfoex 

I've checked ctype docu included in python but don't find any hint about your 
concerns.
May I ask you, do you know additional documents/sites which I can use to get a 
better understanding
about caching issue? Or did I miss something from used documentation?

> The attribute name is "_fields_", not "__fields__", so you haven't 
> actually defined any fields and sizeof(ICONINFO) is 0. When you pass 
> this empty struct to GetIconInfo, it potentially overwrites and 
> corrupts existing data on the heap that can lead to a crash later on. 

Ahhh, typically me. Thank you for pointing to it.

> Here's the setup I created to test GetIconInfo and GetIconInfoEx. 
> Maybe you can reuse some of this code, but if you're using XP this 
> won't work as written because GetIconInfoEx was added in Vista. 

> Note the use of a __del__ finalizer to call DeleteObject on the 
> bitmaps. Otherwise, in a real application, calling GetIconInfo would 
> leak memory. 

Oh, you answered already an upcoming question I guess, thank you ;-)

> Using __del__ is convenient, but note that you can't 
> reuse an instance without manually calling DeleteObject on the 
> bitmaps. 
Don't understand this. Isn't this covered by your example in base class?

class ICONINFO_BASE(ctypes.Structure): 
def __del__(self, gdi32=gdi32): 
if self.hbmMask: 
gdi32.DeleteObject(self.hbmMask) 
self.hbmMask = None 
if self.hbmColor: 
gdi32.DeleteObject(self.hbmColor) 
self.hbmColor = None 

If I would do somthing like

iconinfoex = ICONINFOEX()
iconinfoex = None

DeleteObject would be called once None gets assigned, wouldn't it?

Again, thank you very much.
Hubert
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26156] Bad name into power operator syntax

2016-05-06 Thread R. David Murray

R. David Murray added the comment:

Sounds like it is a bit more than just confusion: given that power can be used 
outside a coroutine but await can't, Serhiy's formulation would seem to me to 
be more semantically correct, even if syntactically it is the same as the 
current.

I think it would regardless be better to replace 'await' with 'await_expr', so 
+1 on that from me as well.

--
nosy: +r.david.murray

___
Python tracker 

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



  1   2   >