[issue26143] Ensure that IDLE's stdlib imports are from the stdlib

2017-04-30 Thread Louie Lu

Louie Lu added the comment:

Because sys module is correctly imported, we can modify sys.path to change the 
import behave.

Add new PR 1364 for this.

This add a new private function `_fix_import_path` that will remove the local 
import path `''`, when running IDLE from command line, it will recover the 
import path at the end of the argparse part. So no need to worry about user to 
import other local modules.

That also mean, if our user has the same name file, they will not be able to 
import it anymore. (cause IDLE import it first).

--
nosy: +louielu

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



[issue26143] Ensure that IDLE's stdlib imports are from the stdlib

2017-04-30 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +1474

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



[issue30200] tkinter ListboxSelect

2017-04-29 Thread Louie Lu

Louie Lu added the comment:

This behavior is as same as on my Linux Python 2.7.13:


(, (2,)) # Select Font
(, (3,)) # Select Style
(, ())   # Deselect Font


And also, you don't need a try expect to handle this situation. You can see 
that when de-select the listbox, curselection() will return an empty tuple, you 
only need an if statement to handle this:

def get_style(event):
lb_sty_cur = event.widget.curselection()
if lb_sty_cur:
lb_sty_get = listbox_style.get(lb_sty_cur)
self.style.set(lb_sty_get)
return

--

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



[issue30200] tkinter ListboxSelect

2017-04-29 Thread Louie Lu

Louie Lu added the comment:

I think this is only a normal behavior now.


Generate two events make sense, they are generate by different widget:

.!editor.!font_dialog.!frame.!frame.!listbox (0,)   # Select Font
.!editor.!font_dialog.!frame2.!frame.!listbox (0,)  # Select Style
.!editor.!font_dialog.!frame.!frame.!listbox () # Deselect Font

When you select one list and trying to select another listbox,
you will trigger two event, first is the select, and second the de-select.

So you will need to handle the de-select part.

--

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



[issue30200] tkinter ListboxSelect

2017-04-29 Thread Louie Lu

Louie Lu added the comment:

But I'm not sure if this is a behavior error or something else, I'm still 
trying to find the root cause.

--

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



[issue30200] tkinter ListboxSelect

2017-04-29 Thread Louie Lu

Louie Lu added the comment:

The problem cause by listbox.curselection(). When crossing from a listbox to 
another listbox, it will trigger twice event.

The first time get a valid select tuple from curselection() (which will return 
(index, label)), and the second time will generate empty tuple.

You should check curselection()'s tuple before passing into listbox.get(). The 
easiest is to add a if stmt for lb_*_cur, for example:


def get_style(event):
# self.style.set(listbox_style.get(listbox_style.curselection()))
# TEST >
lb_sty_cur = listbox_style.curselection()
if lb_sty_cur:
lb_sty_get = listbox_style.get(lb_sty_cur)
self.style.set(lb_sty_get)
return

--

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



[issue30200] tkinter ListboxSelect

2017-04-29 Thread Louie Lu

Louie Lu added the comment:

I can reproduce the problem at 2.7.13 on Linux.


Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1542, in __call__
return self.func(*args)
  File "tests.py", line 174, in get_style
lb_sty_get =  listbox_style.get(lb_sty_cur)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 2629, in get
return self.tk.call(self._w, 'get', first)
TclError: bad listbox index "": must be active, anchor, end, @x,y, or a number

--
nosy: +louielu
versions: +Python 2.7

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



[issue24263] unittest cannot load module whose name starts with Unicode

2017-04-28 Thread Louie Lu

Louie Lu added the comment:

Add PR: https://github.com/python/cpython/pull/1338/


rbcollins: Need for help to review the patch, I think that both `$thing` and 
`$thing.py` can't be used in python (and for UNIX dir), and `\u2603` (☃) though 
can do something like `☃.py`, but it is not a valid identifier in python, too.

--
nosy: +louielu

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



[issue24263] unittest cannot load module whose name starts with Unicode

2017-04-28 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +1449

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



[issue30181] Incorrect parsing of test case docstring

2017-04-26 Thread Louie Lu

Louie Lu added the comment:

This is because unittest.TestCase method `shortDescription()` will only return 
the first line of docstring, writing at here*:

"""
The default implementation of this method returns the first line of the test 
method’s docstring, if available, or None.
"""

Not sure if we may change this default behavior for this.



* 
https://docs.python.org/3/library/unittest.html#unittest.TestCase.shortDescription

--
nosy: +louielu

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



[issue30182] Incorrect in referring to ISO as "International Standards Organization"

2017-04-26 Thread Louie Lu

Louie Lu added the comment:

Add the link: 

Python 3: https://docs.python.org/3/howto/unicode.html
Python 2: https://docs.python.org/2/howto/unicode.html

Both of 2 and 3 howto unicode use "International Standards Organization"


Jesse, would you like to create a PR for this?

--
nosy: +louielu
versions: +Python 2.7, Python 3.7

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



[issue28964] AST literal_eval exceptions provide no information about line number

2017-04-26 Thread Louie Lu

Louie Lu added the comment:

Steve, will you work on this patch to GitHub?

--
nosy: +louielu

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



[issue28698] Python 3.x ctypes c_wchar_p return is different from official documentation example

2017-04-26 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +1399

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



[issue28698] Python 3.x ctypes c_wchar_p return is different from official documentation example

2017-04-26 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +1398

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



[issue18943] argparse: default args in mutually exclusive groups

2017-04-26 Thread Louie Lu

Louie Lu added the comment:

paul, will you work on this patch? or I can help this issue, too.

--
nosy: +louielu
type:  -> behavior
versions: +Python 3.7

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



[issue19184] dis module has incorrect docs for RAISE_VARARGS

2017-04-26 Thread Louie Lu

Louie Lu added the comment:

I've made a PR, could serhiy or georg help for review?
Thanks!

--
nosy: +louielu

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



[issue30013] Compiler warning in Modules/posixmodule.c

2017-04-26 Thread Louie Lu

Louie Lu added the comment:

serhiy, haypo, what do you think about this warning's fixed?

Thanks!

--
nosy: +haypo, serhiy.storchaka

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



[issue30163] argparse mx_group is required, when action value equal default will be ignore

2017-04-26 Thread Louie Lu

Louie Lu added the comment:

Thanks, paul. Your msg help a lot.

Will you work on #18943? I can help for this or review the pending patch.

--
resolution:  -> duplicate

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



[issue30163] argparse mx_group is required, when action value equal default will be ignore

2017-04-25 Thread Louie Lu

Louie Lu added the comment:

Maybe documentation should note that:
"""
# error if this argument is not allowed with other previously
# seen arguments, assuming that actions that use the default
# value don't really count as "present"
"""

--

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



[issue21150] Add quick links table to argparse docs

2017-04-25 Thread Louie Lu

Louie Lu added the comment:

Could Raymond, Gaurav or paul help to review the PR's summary table?
Thanks!

--

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



[issue30163] argparse mx_group is required, when action value equal default will be ignore

2017-04-25 Thread Louie Lu

Louie Lu added the comment:

Strange, this will only trigger when that argument type is int.

--

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



[issue30163] argparse mx_group is required, when action value equal default will be ignore

2017-04-25 Thread Louie Lu

New submission from Louie Lu:

When adding mutually exclusive group and required is True, and the group 
argument has default value. If we type its default value, argparse will ignore 
the input and return `argument is required`


--- PoC 
import argparse

parser = argparse.ArgumentParser()
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-v', type=int, default=10)

print(parser.parse_args())

-

$ python tests.py -v 10
usage: tests.py [-h] -v V
tests.py: error: one of the arguments -v is required
$ python tests.py -v 11
Namespace(v=11)

--
components: Library (Lib)
messages: 292293
nosy: louielu
priority: normal
severity: normal
status: open
title: argparse mx_group is required, when action value equal default will be 
ignore
versions: Python 3.7

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



[issue30163] argparse mx_group is required, when action value equal default will be ignore

2017-04-25 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
type:  -> behavior

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



[issue30157] csv.Sniffer.sniff() regex error

2017-04-24 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
title: csn.Sniffer.sniff() regex error -> csv.Sniffer.sniff() regex error

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



[issue9285] Add a profile decorator to profile and cProfile

2017-04-22 Thread Louie Lu

Louie Lu added the comment:

Giampaolo, the assertion is still worked good, and no need to remove them. The 
assertion is to prevent dispatch return too more, to return upper then when the 
profiler was created.

The problem why profile __enter__ can't work, is because it misses the 
simulate_call between __enter__ and upper frame.

The original scenes:

pr = profile.Profile()  # It will call simulate_call at the end of init
sys.setprofile(pr.dispatcher)
# profile
sys.setprofile(None)

The break scenes:

def profile_helper(pr):
sys.setprofile(pr.dispatcher)
# Function will return None, dead here

pr = profile.Profile()  # Create simulate_call
# We go into profile_helper, but didn't simulate a call!! (didn't setprofile 
yet)
profile_helper(pr)  
sys.setprofile(None)

The #30113 issue fix this:

def profile_helper(pr):
pr._adjust_frame()  # call simuate_call here
sys.setprofile(pr.dispatcher)

pr = profile.Profile()  # Create simulate_call
profile_helper(pr)  
sys.setprofile(None)

Creating this simuate_call, then profiler can go back to the upper frame 
without error.

--

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



[issue23420] python -m cProfile -s fails with non informative message

2017-04-22 Thread Louie Lu

Louie Lu added the comment:

If we can solve #30118 for argument unittest, and apply #18971 for optparse to 
argparse, this issue will then can be solve, too.

--
nosy: +louielu

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



[issue29237] Create enum for pstats sorting options

2017-04-22 Thread Louie Lu

Louie Lu added the comment:

Mariatta, is there any movement on this issue?

Thanks!

--
nosy: +louielu

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



[issue18576] Document test.support.script_helper

2017-04-22 Thread Louie Lu

Louie Lu added the comment:

The PR on GitHub is based on bobcatfist's patch, addressed on Martin request 
and some minor change.

--
nosy: +louielu

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



[issue29782] Use __builtin_clzl for bits_in_digit if available

2017-04-22 Thread Louie Lu

Louie Lu added the comment:

If this issue is closed by "not a big performance improvement", maybe the XXX 
in mathmoudle.c should be take off?

"""
/* XXX: This routine does more or less the same thing as
 * bits_in_digit() in Objects/longobject.c.  Someday it would be nice to
 * consolidate them.  On BSD, there's a library function called fls()
 * that we could use, and GCC provides __builtin_clz().
 */
"""

--
nosy: +louielu

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



[issue30113] Allow helper functions to wrap sys.setprofile

2017-04-22 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +1368

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



[issue30113] Allow helper functions to wrap sys.setprofile

2017-04-22 Thread Louie Lu

Louie Lu added the comment:

Thanks, Nick. Your analysis is very helpful.


After some testing, I found the problem here is because when we using 
`sys.setprofile` in the helper function, we didn't simulate the call (from 
where profiler create to helper function), that cause profile's frame link 
breakup, so if we want to return to outside of helper function, it will report 
a bad return.

A straightforward method is the latter method you propose, to make a 
profiler-aware function manually insert the frame into profiler's frame stack:

def _adjust_frame(self):
frame = sys._getframe(1)  # Get helper function frame
self.dispatch['call'](self, frame, 0)

And adjust *before* install profiler:

def profile_helper(pr):
pr._adjust_frame()
sys.setprofile(pr.dispatcher)


Then we can get the correct thing we need.

--

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



[issue18576] Document test.support.script_helper

2017-04-22 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +1367

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



[issue30136] Add test.support.script_helper to documentation

2017-04-21 Thread Louie Lu

New submission from Louie Lu:

`test.support.script_helper` didn't document at `test` document.

It should be add on.

--
assignee: docs@python
components: Documentation
messages: 292103
nosy: docs@python, louielu
priority: normal
severity: normal
status: open
title: Add test.support.script_helper to documentation
versions: Python 3.7

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



[issue30118] Adding unittest for cProfile / profile command line interface

2017-04-21 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +1350

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



[issue18971] Use argparse in the profile/cProfile modules

2017-04-20 Thread Louie Lu

Louie Lu added the comment:

haypo, murray, thanks for pointing this thing, I will let go about the bad 
message test, move to output file and sort test tomorrow, also add a new issue: 
#30118

--

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



[issue30118] Adding unittest for cProfile / profile command line interface

2017-04-20 Thread Louie Lu

New submission from Louie Lu:

Serhiy provide a cProfile / profile CLI optparse to argparse patch in #18971, 
it is time to add up the unittest of CLI test.

I'll add the unittest these days for it.

--
components: Library (Lib)
messages: 291981
nosy: louielu, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Adding unittest for cProfile / profile command line interface
versions: Python 3.7

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



[issue18971] Use argparse in the profile/cProfile modules

2017-04-20 Thread Louie Lu

Louie Lu added the comment:

bad news, somehow the output of std.err and std.out have different between 
optparse and argparse, even if the test is done, it still need to convert some 
testcase to argparse compatible.

--
nosy: +louielu

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



[issue9285] Add a profile decorator to profile and cProfile

2017-04-20 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +1335

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



[issue30113] Add profile test case for trace_dispatch_return assertion

2017-04-20 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +1334

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



[issue30113] Add profile test case for trace_dispatch_return assertion

2017-04-20 Thread Louie Lu

New submission from Louie Lu:

This is a sub-problem of #9285, in #9285, we aim to provide cProfile and 
profile a context manager, this will need to add code like this:

def __enter__(self):
self.set_cmd('')
sys.setprofile(self.dispatcher)
return self

Unfortunately, when setting up profiler via `sys.setprofile`, it will 
immediately work on next line `return self`, which cause the assertion inside 
`trace_dispatch_return` claim this is a "Bad return".

Technically, `profile.Profile` can not go return upper than it's frame inside 
the frame stack. This behavior can be observed by this code:

def fib(n):
if n > 2:
return fib(n - 1) + fib(n - 2)
return n

def foo():
pr = profile.Profile()
# Profile was set in the `foo` frame, it can't get more upper than this
# that means, we can't return to global frame when this profile is set
sys.setprofile(pr.dispatcher)
fib(5)
# We didn't stop the profile here via sys.setprofile(None)
# So it will return 0xDEADBEAF to global frame and cause a bad return
return 0xDEADBEAF

foo()

Here this issue will provide the test of this behavior, then will make some 
modify in #9285 to prevent this situation when using profile as a context 
manager.

--
components: Library (Lib)
messages: 291957
nosy: louielu, ncoghlan
priority: normal
severity: normal
status: open
title: Add profile test case for trace_dispatch_return assertion
type: enhancement
versions: Python 3.7

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



[issue30112] useful things

2017-04-20 Thread Louie Lu

Louie Lu added the comment:

Please don't click the link, Google chrome return a security error

"""
Attackers on www.arqja.com may trick you into doing something dangerous like 
installing software or revealing your personal information (for example, 
passwords, phone numbers, or credit cards).
"""

--
nosy: +louielu

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



[issue21150] Add quick links table to argparse docs

2017-04-20 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +1332

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



[issue21150] Add quick links table to argparse docs

2017-04-19 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
nosy: +louielu

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



[issue30078] "-m unittest --help" says nothing about direct script exection

2017-04-19 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +1306

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



[issue30078] "-m unittest --help" says nothing about direct script exection

2017-04-19 Thread Louie Lu

Louie Lu added the comment:

Add a simple line to `MAIN_EXAMPLES`:

"%(prog)s path/to/test_file.py  - run tests from test_file.py"

--
nosy: +louielu

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



[issue14102] argparse: add ability to create a man page

2017-04-19 Thread Louie Lu

Louie Lu added the comment:

Sorry that I didn't figure out what you said in the previous msg.

> provide a command-line interface for an end user

I add a parameter that developer can switch command line option for man page, 
if the option is on, user can do this:

./python foo.py --manpage

and open the manpage, but I think this isn't a good approach, since normal user 
will simply use `man foo.py`.

> generate a man page in a build script.
> Do you mean that the programmer should create a separate script for 
> generating a man page and copy a part of the code from the main program? This 
> workflow should be documented, with examples. And it is not applicable for 
> simple one-file scripts.

I not sure if argparse need to provide a setuptools command, if need, the 
approach that Oz provide can be used, and developer only need to do like this 
in setup.py

from argparser import build_manpage
cmdclass={'build_manpage': build_manpage}

then at the command line, developer can build manpage as `./python setup.py 
build_manpage --output=foo.1 --parser=foo.parser`

If provide this is function too far for argparse, then as you said, a 
well-documented workflow should be provided.



Even if argparse provide this function, end-user still can't easily do the 
trick `man foo.py` or `man foo` if script point is provide in setup.py. If need 
to approach things like `man foo`, it may need to integrate with setuptools to 
put the man page file to the correct path (e.g. /usr/share/man/man1)

--

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



[issue14102] argparse: add ability to create a man page

2017-04-19 Thread Louie Lu

Louie Lu added the comment:

Also, `print_manpage` use the same infra as `print_help` and `print_usage`, so 
it can use the parameter `file` to output to different stream or file.

--

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



[issue14102] argparse: add ability to create a man page

2017-04-19 Thread Louie Lu

Louie Lu added the comment:

Attachment is the poc of generating man page via `print_manpage`:

$ ./python poc_2.py > output && man ./output

--
Added file: http://bugs.python.org/file46812/poc_2.py

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



[issue14102] argparse: add ability to create a man page

2017-04-19 Thread Louie Lu

Louie Lu added the comment:

> How to use this feature?
> argparse is executed every time when the end user runs the program.
> But generating a man page is the action that should be executed at
> develop or build stage.
> ...
> How generating a man page should be invoked?

For now, man page will only be generated by using `print_manpage` function, and 
argparse won't add a shortcut like help page (-h).

Developer can use `parser.add_manpage_section` to add custom manpage section, 
e.g. copyright, report bugs.

The only thing that will affect it that `add_manpage_section` will be adding at 
runtime, but user won't used it.


> The end user gets a generated man page, he doesn't need the option to 
> generate a man page on a fly. The developer needs the ability to generate a 
> man page rather than running the program for its main purpose.

Yes, this patch will only offer the ability to generate man page, but if 
developer want to build with `setup.py`, it still need to combine them.


> What should be the structure of the program that uses argparse for parsing 
> arguments and for generating a man page?

It won't need additional change, just used current method and it will work.

--

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



[issue14102] argparse: add ability to create a man page

2017-04-18 Thread Louie Lu

Louie Lu added the comment:

Hi all, I've created a PR for this, please help for code review.

I found that previous method from Oz had a problem, that man page and general 
help page will share a Formatter, that cause an unexpected behavior that help 
page will generate with troff format (Unix man page used this format).

I switch to another method that creates a Manpage class and a private 
_ManpageFormatter, we just need to put parser into this Manpage, the __str__ 
method will generate the man page that we want.

This approach prevents help page format affect by ManpageFormatter, and the 
user can happily switching formatter_class to RawDescriptionHelpForatter, 
RawTextHelpForatter and others, since the Manpage class is separate from 
HelpFormatter, and _ManpageFormatter will used the formatter provide from 
parser.

The attach file is a dummy argparser file, you can try it by this:

  ./python poc.py > poc.1 && man ./poc.1

--
nosy: +louielu
Added file: http://bugs.python.org/file46809/poc.py

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



[issue14102] argparse: add ability to create a man page

2017-04-18 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +1300

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



[issue30031] Improve queens demo (use argparse and singular form)

2017-04-17 Thread Louie Lu

Louie Lu added the comment:

Pavlo, you are right, making the argument have backward compatible is good. 
String quote I'll prefer `'` more than `"`.

--

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



[issue30090] Failed to build these modules: _ctypes

2017-04-17 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
components: +Build -Interpreter Core
type: compile error -> 

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



[issue30090] Failed to build these modules: _ctypes

2017-04-17 Thread Louie Lu

Louie Lu added the comment:

Are you using Ubuntu or other Linux distribution? This problem is because you 
didn't install the dependency package.

You may first try to use the instruction at devguide:
http://cpython-devguide.readthedocs.io/setup.html#build-dependencies

Or, assume you have install build-essential and python3-dev ...etc., maybe you 
lost to install libffi-dev, just simply `apt-get install libffi-dev` and 
rebuild to solve this problem.

--
nosy: +louielu

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



[issue30031] Improve queens demo (use argparse and singular form)

2017-04-17 Thread Louie Lu

Louie Lu added the comment:

I make some review at GitHub.

Do David and Terry suggest to also fix the problem about PEP8 coding style, 
since this demo have many places didn't fit PEP8.

--
nosy: +louielu

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



[issue30088] mailbox.Maildir doesn't create subdir structure when create=True and base dir exists

2017-04-17 Thread Louie Lu

Louie Lu added the comment:

I think this patch make the behavior changed.

Documentation wrote that: "If create is True, the mailbox is created if it does 
not exist.", the current version did that exactly, it won't create subdir (tmp, 
new, and cur) when dir exists.

The situation face here is that TemporaryDirectory() create a valid dir without 
Maildir structure subdir (tmp, new, and cur), and the `create` parameter won't 
create subdir (because the dir is exist!).

Not sure if this behavior change is worth or not. I'll also upload an PoC for 
this.

--
nosy: +louielu
Added file: http://bugs.python.org/file46808/poc.py

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



[issue30040] new empty dict can be more small

2017-04-17 Thread Louie Lu

Louie Lu added the comment:

I'm testing[1] that if we make a fast path that detect if keys is 
`empty_keys_struct` inside `dictresize`. It can be faster than original patch, 
but still slower than default (unpatch) in most case.


➜  cpython git:(compact_empty_dict) ✗ ./python.default -m perf compare_to -G 
--min-speed=1 default.json lpatch.json  
Slower (14):
- pickle_dict: 91.1 us +- 2.2 us -> 98.0 us +- 3.3 us: 1.08x slower (+8%)
- xml_etree_parse: 534 ms +- 29 ms -> 565 ms +- 27 ms: 1.06x slower (+6%)
- crypto_pyaes: 679 ms +- 22 ms -> 708 ms +- 22 ms: 1.04x slower (+4%)
- regex_effbot: 12.1 ms +- 0.2 ms -> 12.6 ms +- 0.2 ms: 1.04x slower (+4%)
- tornado_http: 678 ms +- 21 ms -> 704 ms +- 31 ms: 1.04x slower (+4%)
- pidigits: 432 ms +- 7 ms -> 447 ms +- 18 ms: 1.03x slower (+3%)
- spectral_norm: 869 ms +- 21 ms -> 898 ms +- 22 ms: 1.03x slower (+3%)
- unpickle_list: 20.6 us +- 0.6 us -> 21.2 us +- 0.8 us: 1.03x slower (+3%)
- pathlib: 87.9 ms +- 3.0 ms -> 90.6 ms +- 3.5 ms: 1.03x slower (+3%)
- pickle_list: 13.0 us +- 0.3 us -> 13.3 us +- 0.4 us: 1.03x slower (+3%)
- meteor_contest: 367 ms +- 13 ms -> 378 ms +- 14 ms: 1.03x slower (+3%)
- scimark_sor: 991 ms +- 28 ms -> 1.02 sec +- 0.03 sec: 1.03x slower (+3%)
- sympy_expand: 1.73 sec +- 0.05 sec -> 1.77 sec +- 0.04 sec: 1.02x slower (+2%)
- python_startup: 29.5 ms +- 1.1 ms -> 30.1 ms +- 1.9 ms: 1.02x slower (+2%)

Faster (8):
- sympy_integrate: 84.3 ms +- 8.3 ms -> 78.3 ms +- 5.0 ms: 1.08x faster (-7%)
- call_simple: 30.6 ms +- 1.7 ms -> 29.0 ms +- 1.4 ms: 1.06x faster (-5%)
- pickle: 43.2 us +- 3.2 us -> 41.1 us +- 1.9 us: 1.05x faster (-5%)
- call_method_unknown: 36.4 ms +- 1.6 ms -> 35.0 ms +- 1.5 ms: 1.04x faster 
(-4%)
- scimark_lu: 781 ms +- 42 ms -> 752 ms +- 34 ms: 1.04x faster (-4%)
- sympy_sum: 385 ms +- 21 ms -> 372 ms +- 17 ms: 1.03x faster (-3%)
- logging_silent: 1.30 us +- 0.04 us -> 1.26 us +- 0.04 us: 1.03x faster (-3%)
- django_template: 665 ms +- 20 ms -> 643 ms +- 18 ms: 1.03x faster (-3%)

Benchmark hidden because not significant (42)

[1]: 
https://github.com/lulouie/cpython/blob/compact_empty_dict/Objects/dictobject.c#L1247

--

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



[issue30040] new empty dict can be more small

2017-04-16 Thread Louie Lu

Louie Lu added the comment:

forgive my words, I trace the wrong code, sorry about that.

--

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



[issue30040] new empty dict can be more small

2017-04-16 Thread Louie Lu

Louie Lu added the comment:

Inada's patch version act different inside `PyObject_SetItem`, 

when running this code: 'x = {}; x['a'] = 123'

at PyObject_SetItem,

patch version goes to this line:
  >│179 if (m && m->mp_ass_subscript)
   │180 return m->mp_ass_subscript(o, key, value);

but original version goes to:
  >│182 if (o->ob_type->tp_as_sequence) {
   │183 if (PyIndex_Check(key)) {

I think that's why the performance issue came out, still digging why this 
happened.

--
nosy: +louielu

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



[issue28698] Python 3.x ctypes c_wchar_p return is different from official documentation example

2017-04-15 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +1289

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



[issue19184] dis module has incorrect docs for RAISE_VARARGS

2017-04-15 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +1288

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



[issue25794] __setattr__ does not always overload operators

2017-04-14 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
nosy: +louielu

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



[issue29881] Add a new private API clear private variables, which are initialized once, at Python shutdown

2017-04-11 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
nosy: +louielu

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



[issue24076] sum() several times slower on Python 3 64-bit

2017-04-11 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
title: sum() several times slower on Python 3 -> sum() several times slower on 
Python 3 64-bit

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



[issue24076] sum() several times slower on Python 3

2017-04-11 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
versions: +Python 3.7

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



[issue25828] PyCode_Optimize() (peephole optimizer) doesn't handle KeyboardInterrupt correctly

2017-04-11 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +1221

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



[issue25828] PyCode_Optimize() (peephole optimizer) doesn't handle KeyboardInterrupt correctly

2017-04-11 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
versions: +Python 3.7

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



[issue30013] Compiler warning in Modules/posixmodule.c

2017-04-07 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +1184

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



[issue30013] Compiler warning in Modules/posixmodule.c

2017-04-07 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
title: Compiling warning in Modules/posixmodule.c -> Compiler warning in 
Modules/posixmodule.c

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



[issue30013] Compiling warning in Modules/posixmodule.c

2017-04-07 Thread Louie Lu

New submission from Louie Lu:

Using gcc-6.3.1 20170306 on Linux 4.10.1, it gave the warning:

gcc -pthread -c -Wno-unused-result -Wsign-compare -g -Og -Wall 
-Wstrict-prototypes-std=c99 -Wextra -Wno-unused-result 
-Wno-unused-parameter -Wno-missing-field-initializers 
-Werror=implicit-function-declaration   -I. -I./Include-DPy_BUILD_CORE -o 
Python/pyctype.o Python/pyctype.c
:./Modules/posixmodule.c: In function ‘os_major_impl’:
./Modules/posixmodule.c:8584:13: warning: In the GNU C Library, "major" is 
defined
 by . For historical compatibility, it is
 currently defined by  as well, but we plan to
 remove this soon. To use "major", include 
 directly. If you did not intend to use a system-defined macro
 "major", you should undefine it after including .
 return major(device);
 ^  



 
./Modules/posixmodule.c: In function ‘os_minor_impl’:
./Modules/posixmodule.c:8601:13: warning: In the GNU C Library, "minor" is 
defined
 by . For historical compatibility, it is
 currently defined by  as well, but we plan to
 remove this soon. To use "minor", include 
 directly. If you did not intend to use a system-defined macro
 "minor", you should undefine it after including .
 return minor(device);
 ^  



 
./Modules/posixmodule.c: In function ‘os_makedev_impl’:
./Modules/posixmodule.c:8619:13: warning: In the GNU C Library, "makedev" is 
defined
 by . For historical compatibility, it is
 currently defined by  as well, but we plan to
 remove this soon. To use "makedev", include 
 directly. If you did not intend to use a system-defined macro
 "makedev", you should undefine it after including .
 return makedev(major, minor);
 ^  


The problem introduce in glibc 2.25, going to deprecate the definition of 
'major', 'minor', and 'makedev' by  sys/types.h. And the autoconf didn't change 
the behavior of `AC_HEADER_MAJOR`, see:

https://lists.gnu.org/archive/html/autoconf/2016-08/msg00014.html


There is a workaround path for this in libvirt, which take from autoconf patch, 
see:

https://www.redhat.com/archives/libvir-list/2016-September/msg00459.html

--
components: Extension Modules
messages: 291260
nosy: louielu
priority: normal
severity: normal
status: open
title: Compiling warning in Modules/posixmodule.c
type: compile error
versions: Python 3.7

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



[issue29446] Improve tkinter 'import *' situation

2017-04-04 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
nosy: +louielu

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



[issue29981] Update Index for set, dict, and generator 'comprehensions'

2017-04-04 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +1170

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



[issue29981] Update Index for set, dict, and generator 'comprehensions'

2017-04-04 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
nosy: +louielu

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



[issue29946] compiler warning "sqrtpi defined but not used"

2017-03-30 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +808

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



[issue29946] compiler warning "sqrtpi defined but not used"

2017-03-30 Thread Louie Lu

Louie Lu added the comment:

I can reproduce on ArchLinux 4.10.1-1, GCC 6.3.1:

/home/louielu/Python/cpython/Modules/mathmodule.c:74:21: warning: ‘sqrtpi’ 
defined but not used [-Wunused-const-variable=]
 static const double sqrtpi = 1.772453850905516027298167483341145182798;



Is used by `m_erfc_contfrac` and `m_erf_series`, and inside the block of "#if 
!defined(HAVE_ERF) || !defined(HAVE_ERFC)", maybe sqrtpi should do the same 
condition?

--
nosy: +louielu

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



[issue26440] tarfile._FileInFile.seekable is broken in stream mode

2017-03-29 Thread Louie Lu

Louie Lu added the comment:

Actually, _Stream does provide seek method, should the seekable just return 
True?

--
nosy: +louielu

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



[issue28415] PyUnicode_FromFormat integer format handling different from printf about zeropad

2017-03-29 Thread Louie Lu

Louie Lu added the comment:

Add a note block under Py*_FromFormat in unicode.rst and bytes.rst.

Could Xiang or Terry help to review? Thanks.

--
nosy: +louielu

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



[issue28415] PyUnicode_FromFormat integer format handling different from printf about zeropad

2017-03-29 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +787

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



[issue24821] The optimization of string search can cause pessimization

2017-03-29 Thread Louie Lu

Louie Lu added the comment:

I can now only test on Python3.6, providing much meaningful sentence,
still trying to use perf on cpython master branch.

---

$ python -m perf timeit -s 's="一件乒乓事事亏, 不乏串連产業, 万丈一争今为举, 其乎哀哉"*1000' -- 
's.find("乎")'

Median +- std dev: 228 ns +- 7 ns


$ python -m perf timeit -s 's="一件乒乓事事亏, 不乏串連产業, 万丈一争今为举, 其乎哀哉"*1000' -- 
's.find("乏")'  

Median +- std dev: 143 ns +- 3 ns

---

$ python -m perf timeit -s 's="一件乒乓事事亏, 不乏串連产業, 万丈一争今为举, 其哀哉"*1000' -- 
's.find("乎")'  
   ^^ 
(missing "乎")
Median +- std dev: 100 us +- 3 us

$ python -m perf timeit -s 's="一件乒乓事事亏, 不串連产業, 万丈一争今为举, 其乎哀哉"*1000' -- 
's.find("乏")'
 ^^ (missing "乏")
Median +- std dev: 1.67 us +- 0.05 us

--
nosy: +louielu

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



[issue29927] Unnecessary code in the c-api/exceptions.c

2017-03-28 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +767

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



[issue29927] Unnecessary code in the c-api/exceptions.c

2017-03-28 Thread Louie Lu

Louie Lu added the comment:

It seems somehow the patch at #3295 make the mistake, commit faa54a39295 at 
2007-08-19 add the PRE_INIT(BufferError) and POST_INIT(BufferError), but in 
#3295 `buffererror.patch` didn't saw it.

--
nosy: +louielu

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



[issue29890] Constructor of ipaddress.IPv*Interface does not follow documentation

2017-03-25 Thread Louie Lu

Louie Lu added the comment:

Add unittest. Since IPv6 do not support prefix netmask (':ff00::'), it have 
only test like this:

>>> a = ipaddress.ip_interface(('dead:beaf::', '32'))
>>> b = ipaddress.ip_interface('dead:beaf::/32')
>>> str(a) == str(b)

--

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



[issue29890] Constructor of ipaddress.IPv*Interface does not follow documentation

2017-03-25 Thread Louie Lu

Louie Lu added the comment:

Eric: I made the patch, reference to which IPv*Network dealing with tuple. 
Should I also add the unittest for it?

Also, can you help me code review this, thanks.

--

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



[issue29890] Constructor of ipaddress.IPv*Interface does not follow documentation

2017-03-25 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +722

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



[issue29890] Constructor of ipaddress.IPv*Interface does not follow documentation

2017-03-24 Thread Louie Lu

Louie Lu added the comment:

The document here says: 
https://docs.python.org/3/library/ipaddress.html#interface-objects

""IPv4Interface is a subclass of IPv4Address""

trying with:

>>> ipaddress.IPv4Address(('192.168.128.0', '255.255.255.0'))
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.6/ipaddress.py", line 1284, in __init__
self._ip = self._ip_int_from_string(addr_str)
  File "/usr/lib/python3.6/ipaddress.py", line 1118, in _ip_int_from_string
raise AddressValueError("Expected 4 octets in %r" % ip_str)
ipaddress.AddressValueError: Expected 4 octets in "('192.168.128.0', 
'255.255.255.0')"

So the behavior of IPv4Interface seem to be correct?

--
nosy: +louielu

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



[issue23578] struct.pack error messages do not indicate which argument was invalid

2017-02-25 Thread Louie Lu

Louie Lu added the comment:

> 1. Using global variable doesn't look good to me.

That's true, but I'm not sure if there have other methods to do this.

If not using global variable, we will need to change a bunch of the
function arguments. Since the arguments didn't contain the
information about which item is in the process and raise the error.


> 2. "at offset 1" looks confusing to me. What is offset?

Make the change to: 
>>> struct.pack('hh', , 0x7, 0x8)
struct.error: 'h' format requires -32768 <= number <= 32767, got bad value at 
item 2

(or probably, "got bad value at index 2")

> 3. It is not safe to use the fixed length array for formatting error message. 
> Once the underlying error message can be changed and will overflow the buffer.

Change to snprintf.

> The "%zd" format in sprintf() is not portable.

Change to "%ld"

--

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



[issue23578] struct.pack error messages do not indicate which argument was invalid

2017-02-25 Thread Louie Lu

Louie Lu added the comment:

Adding PyErr_SetString and PyErr_Format wrapper, with a global offset
variable to handle this.

struct.pack('!h', 0x8)
Traceback (most recent call last):
  File "tests.py", line 5, in 
struct.pack('!h', 0x8)
struct.error: Raise at offset 1, 'h' format requires -32768 <= number <= 32767

--
nosy: +louielu

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



[issue23578] struct.pack error messages do not indicate which argument was invalid

2017-02-25 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +262

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



[issue29649] struct.pack_into check boundary error message didn't respect offset

2017-02-25 Thread Louie Lu

New submission from Louie Lu:

For this situation, check boundary error message didn't correctly show out.

>>> import struct
>>> import ctypes
>>> byte_list = ctypes.create_string_buffer(1)
>>> struct.pack_into('b', byte_list, 5, 1)
Traceback (most recent call last):
  File "", line 1, in 
struct.error: pack_into requires a buffer of at least 1 bytes

Since offset is setting at 5, it should at least need `offset + soself->s_size` 
bytes to store it.

--
components: Extension Modules
messages: 288564
nosy: louielu
priority: normal
severity: normal
status: open
title: struct.pack_into check boundary error message didn't respect offset
versions: Python 3.7

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



[issue29645] webbrowser module import has heavy side effects

2017-02-25 Thread Louie Lu

Louie Lu added the comment:

What is the different of Cold start and Hot start? It that CPU speed or 
something else.

In Linux 4.9.11 with i7-2k, I can't reproduce the significant real time you 
gave:

# CPU gov powersave
$ time ./python -c 'import webbrowser'
0.16s user 0.02s system 93% cpu 0.200 total

# CPU gov performance
$ time ./python -c 'import webbrowser'
0.08s user 0.00s system 82% cpu 0.093 total

--
nosy: +louielu

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



[issue9285] Add a profile decorator to profile and cProfile

2017-02-24 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +257

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



[issue9285] Add a profile decorator to profile and cProfile

2017-02-24 Thread Louie Lu

Louie Lu added the comment:

giampaolo: it seems that contextmanager will somehow make a bad return in  
`trace_dispatch_return`:

$ ./python tests.py
# logging.fatal('%r %r' % (frame.f_code.co_name, self.cur[-3]))
CRITICAL:root:'runblock' '' ('profile', 0, '')
CRITICAL:root:'__enter__' '' ('profile', 0, '')
Traceback (most recent call last):
  File "tests.py", line 18, in 
with p.runblock():
  File "/home/grd/Python/cpython/Lib/contextlib.py", line 82, in __enter__
return next(self.gen)
  File "/home/grd/Python/cpython/Lib/profile.py", line 256, in trace_dispatch_i
if self.dispatch[event](self, frame, t):
  File "/home/grd/Python/cpython/Lib/profile.py", line 346, in 
trace_dispatch_return
raise AssertionError("Bad return", self.cur[-3])
AssertionError: ('Bad return', ('profile', 0, ''))

I make a workaround in GitHub PR, that skip the assert when self.cur[-3] is 
('profile', 0, ''), and this work fine with your test cases.

p.s. I'm not very sure about the assertion of bad return, maybe this workaround 
may cause some side affact I didn't notice.

--

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



[issue9285] Add a profile decorator to profile and cProfile

2017-02-24 Thread Louie Lu

Louie Lu added the comment:

Ping. Is there any reason why this patch doesn't accept?

--
nosy: +louielu

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



[issue29634] Reduce deque repeat execution when maxlen exist and size is not 1

2017-02-23 Thread Louie Lu

Louie Lu added the comment:

Raymond: comment has changed, pushed on to GitHub.

--

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



[issue29634] Reduce deque repeat execution when maxlen exist and size is not 1

2017-02-23 Thread Louie Lu

Louie Lu added the comment:

Serhiy: yes, your advice is better than checking inside the loop.

I have updated this to the commit, thanks!

--

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



[issue29634] Reduce deque repeat execution when maxlen exist and size is not 1

2017-02-23 Thread Louie Lu

Changes by Louie Lu <m...@louie.lu>:


--
pull_requests: +223

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



[issue29634] Reduce deque repeat execution when maxlen exist and size is not 1

2017-02-23 Thread Louie Lu

New submission from Louie Lu:

There is a XXX in v3.5.0 shows that need to dealing with deque maxlen setting 
case in deque_repeat.

Although there have common case for deque size 1 with maxlen, other size of 
deque with maxlen still using for-loop to extend the deque, without any 
detection.

Adding this fast break will reduce the execution speed when repeat deque with 
maxlen.

---
$ cat tests.py
from collections import deque
for _ in range(10:
d = deque(maxlen=100_000)
d.insert(0, 0)
d.insert(0, 10)
d * 10_000_000
$ time ./python_with_patch tests.py
$ time ./python tests.py

--
components: Extension Modules
messages: 288460
nosy: louielu
priority: normal
severity: normal
status: open
title: Reduce deque repeat execution when maxlen exist and size is not 1
type: enhancement
versions: Python 3.7

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



[issue28121] If module starts with comment or empty line then frame.f_code.co_firstlineno is inconsistent with inspect.findsource

2017-02-23 Thread Louie Lu

Louie Lu added the comment:

Sorry, but I can't reproduce at 3.7, 3.5, or 2.7.
the result shows me that inspect does respect comment line.

➜  cpython git:(350) ✗ ./python /tmp/main.py
2
(['# First line\n', 'import inspect\n', 'frame = inspect.currentframe()\n', 
'print(frame.f_code.co_firstlineno)\n', 
'print(inspect.findsource(frame.f_code))\n'], 0)

➜  /tmp python2 main.py
2
(['# First line\n', 'import inspect\n', 'frame = inspect.currentframe()\n', 
'print(frame.f_code.co_firstlineno)\n', 
'print(inspect.findsource(frame.f_code))\n'], 0)

--
nosy: +louielu

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



[issue29630] REPL tab-completion triggers code execution

2017-02-23 Thread Louie Lu

Louie Lu added the comment:

Could it be the problem from readline?
Using python 2 with readline trigger same behavior.

--

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



[issue29630] REPL tab-completion triggers code execution

2017-02-23 Thread Louie Lu

Louie Lu added the comment:

I can reproduce the problem in Python 3.7.

--
nosy: +louielu

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



<    1   2   3   4   >