Re: How to get the selected text of the webpage in chrome through python ?

2013-01-08 Thread Bruno Dupuis
call to xclip -o, although there must be a pure python implementation which in turn depends on the python framework you play with (gtk/qt/wx/tk/...). Short answer is : it depends on your system, and it may be easier and more portable if you use a graphical toolkit. cheers. -- Bruno Dupuis

Re: Where to contribute Unicode General Category encoding/decoding

2012-12-13 Thread Bruno Dupuis
On Thu, Dec 13, 2012 at 01:51:00AM -0800, Pander Musubi wrote: Hi all, I have created some handy code to encode and decode Unicode General Categories. To which Python Package should I contribute this? Hi, As said in a recent thread (a graph data structure IIRC), talking about new

[issue16049] Create abstract base classes by inheritance rather than a direct invocation of __metaclass__

2012-12-07 Thread Bruno Dupuis
Bruno Dupuis added the comment: Éric, here is a full patch. I hope the doc isn't too confuse. I think we lack a word meaning 'has XXX as metaclass', we should imagine a term for that. -- keywords: +patch Added file: http://bugs.python.org/file28239/16049.patch

[issue16049] Create abstract base classes by inheritance rather than a direct invocation of __metaclass__

2012-12-07 Thread Bruno Dupuis
Changes by Bruno Dupuis bdup...@lisael.org: Added file: http://bugs.python.org/file28240/16049.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16049

[issue16049] Create abstract base classes by inheritance rather than a direct invocation of __metaclass__

2012-12-07 Thread Bruno Dupuis
Changes by Bruno Dupuis bdup...@lisael.org: Removed file: http://bugs.python.org/file28239/16049.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16049

Re: Confused compare function :)

2012-12-06 Thread Bruno Dupuis
On Thu, Dec 06, 2012 at 04:32:34AM +, Steven D'Aprano wrote: On Thu, 06 Dec 2012 03:22:53 +, Rotwang wrote: On 06/12/2012 00:19, Bruno Dupuis wrote: [...] Another advice: never ever except XXXError: pass at least log, or count, or warn, or anything, but don't pass

why does dead code costs time?

2012-12-05 Thread Bruno Dupuis
be in function loading time... I'll check ceval.c However, isn't there a room for a slight optim here? (in this case, the dead code is obvious, but it may be hidden by complex loops and conditions) Cheers -- Bruno Dupuis -- http://mail.python.org/mailman/listinfo/python-list

Re: why does dead code costs time?

2012-12-05 Thread Bruno Dupuis
On Wed, Dec 05, 2012 at 04:15:59PM +, Neil Cerutti wrote: On 2012-12-05, Bruno Dupuis python.ml.bruno.dup...@lisael.org wrote: Hi, I'm interested in compilers optimizations, so I study python compilation process I ran that script: import timeit def f(x

Re: why does dead code costs time?

2012-12-05 Thread Bruno Dupuis
On Wed, Dec 05, 2012 at 05:40:51PM +0100, Bruno Dupuis wrote: On Wed, Dec 05, 2012 at 04:15:59PM +, Neil Cerutti wrote: Maybe it's the difference between LOAD_CONST and LOAD_GLOBAL. We can wonder why g uses the latter. Good point! I didn't even noticed that. It's weird... Maybe

Re: How does one make argparse print usage when no options are provided on the command line?

2012-12-05 Thread Bruno Dupuis
statement. So they used argparse for everything but the case where no command line args are given. this is quite raw, but i'd add import sys if len(sys.argv) == 1: sys.argv.append('-h') before I call parser.parse_args() Should work -- Bruno Dupuis -- http://mail.python.org/mailman/listinfo

Re: why does dead code costs time?

2012-12-05 Thread Bruno Dupuis
') 42 This one is pretty scary The difference between `return None` and `return` leads to inconsistency and is in contradiction with the specs, AFAIK. I'm glad we pointed this out. -- Bruno Dupuis -- http://mail.python.org/mailman/listinfo/python-list

Re: why does dead code costs time?

2012-12-05 Thread Bruno Dupuis
On Wed, Dec 05, 2012 at 03:41:19PM -0500, Terry Reedy wrote: On 12/5/2012 1:24 PM, Bruno Dupuis wrote: On Wed, Dec 05, 2012 at 10:59:26AM -0700, Ian Kelly wrote: On Wed, Dec 5, 2012 at 10:34 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: The difference is almost certain

Re: why does dead code costs time?

2012-12-05 Thread Bruno Dupuis
I added a patch on the issue tracker. It solves the bug for short (32700 bytes) functions ref : http://bugs.python.org/file28217/16619-1.patch -- Bruno Dupuis -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused compare function :)

2012-12-05 Thread Bruno Dupuis
? is that correct? seems strangee to me. -- Bruno Dupuis -- http://mail.python.org/mailman/listinfo/python-list

[issue16619] LOAD_GLOBAL used to load `None` under certain circumstances

2012-12-05 Thread Bruno Dupuis
New submission from Bruno Dupuis: We found some strange behaviour of the compiler in this discussion on python-list: http://mail.python.org/pipermail/python-list/2012-December/636104.html The fact is, `return` and `return None` result in inconsistent bytecode depending on the context

[issue16619] LOAD_GLOBAL used to load `None` under certain circumstances

2012-12-05 Thread Bruno Dupuis
Bruno Dupuis added the comment: To me, the whole issue is at line ~ 480 in peehole.c in the LOAD_NAME/LOAD_GLOBAL switch case. This explains the difference between `return` and `return None` as the former is actually compiled to LOAD_CONST. OTOH, `return None` has to pass the optim pass

[issue16619] LOAD_GLOBAL used to load `None` under certain circumstances

2012-12-05 Thread Bruno Dupuis
Bruno Dupuis added the comment: line 426 in peehole.c : if (codestr[codelen-1] != RETURN_VALUE) goto exitUnchanged; before the optim. I'm quite sure it's here. i patch and see... -- ___ Python tracker rep...@bugs.python.org http

[issue16619] LOAD_GLOBAL used to load `None` under certain circumstances

2012-12-05 Thread Bruno Dupuis
Bruno Dupuis added the comment: This first patch spots the issue, but doesn't solve it if the bytecode of the function is 32700 (see PyCode_Optimize comment). However with this patch, we get the LOAD_CONST anytime for None, True and False. There is two questions : 1- is it safe to strip all

[issue16619] LOAD_GLOBAL used to load `None` under certain circumstances

2012-12-05 Thread Bruno Dupuis
Bruno Dupuis added the comment: We definitely need to put the code that loads constants with LOAD_CONST out of the optimization code. It's not optim, it's a language feature: None *is* a 'singleton' constant. I'm trying to figure out how to change compile.c to achieve this, as it's my first

[issue887237] Machine integers

2012-12-05 Thread Bruno Dupuis
Changes by Bruno Dupuis bdup...@lisael.org: -- nosy: +bruno.dupuis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue887237 ___ ___ Python-bugs-list

[issue11299] Allow deepcopying and pickling paused generators

2012-12-05 Thread Bruno Dupuis
Changes by Bruno Dupuis bdup...@lisael.org: -- nosy: +bruno.dupuis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11299 ___ ___ Python-bugs-list

[issue15045] Make textwrap.dedent() consistent with str.splitlines(True) and str.strip()

2012-12-05 Thread Bruno Dupuis
Changes by Bruno Dupuis bdup...@lisael.org: -- nosy: +bruno.dupuis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15045 ___ ___ Python-bugs-list

[issue1294232] Error in metaclass search order

2012-12-05 Thread Bruno Dupuis
Changes by Bruno Dupuis bdup...@lisael.org: -- nosy: +bruno.dupuis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1294232 ___ ___ Python-bugs-list

[issue16588] gcc 4.7 unused-but-set warnings on Python/thread_pthread.h

2012-12-01 Thread Bruno Dupuis
Bruno Dupuis added the comment: I don't agree. Trash build logs are bad, trash code (I mean, in terms of utility, not quality :-) ) is far worst IMHO. The purpose of this bug, to me, is to try to find a neat way to suppress the warnings without touching the code, and if we can't, wich

[issue6835] doctest problem with decorated function when decorator is defined in separate file

2012-11-30 Thread Bruno Dupuis
Bruno Dupuis added the comment: updated the test to 3k (requires sh and Python2.{6,7} as python2). It works. Anyone to close? -- nosy: +ezio.melotti, michael.foord Added file: http://bugs.python.org/file28162/mytest3k.sh ___ Python tracker rep

[issue6835] doctest problem with decorated function when decorator is defined in separate file

2012-11-30 Thread Bruno Dupuis
Bruno Dupuis added the comment: it's a duplicate of #1108 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6835 ___ ___ Python-bugs-list mailing

[issue12891] Clean up traces of manifest template in packaging

2012-11-30 Thread Bruno Dupuis
Bruno Dupuis added the comment: Sounds easy even though there's quite a bit of lines to impact. I may do it, I just need a go. Tarek? Éric? anyone? -- nosy: +bruno.dupuis versions: -3rd party ___ Python tracker rep...@bugs.python.org http

[issue10259] Entry text not set if all of 'Font', 'Foreground' and 'Justify' are set

2012-11-30 Thread Bruno Dupuis
Bruno Dupuis added the comment: I updated the script to 3k. Now the behaviour is very odd : Python 2.7: works only if `justify=right` is commented out. Python 3.3: Shroedinger-like behaviour (sometimes dead, sometimes alive, nobody knows before we check) whith `justify=right` Looks like some

[issue6036] Clean up test_posixpath.py

2012-11-30 Thread Bruno Dupuis
Changes by Bruno Dupuis bdup...@lisael.org: -- nosy: +bruno.dupuis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6036 ___ ___ Python-bugs-list

[issue12891] Clean up traces of manifest template in packaging

2012-11-30 Thread Bruno Dupuis
Bruno Dupuis added the comment: Ok, thanks, Èric. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12891 ___ ___ Python-bugs-list mailing list

[issue10259] Entry text not set if all of 'Font', 'Foreground' and 'Justify' are set

2012-11-30 Thread Bruno Dupuis
Bruno Dupuis added the comment: Thank you for the review, Guilherme. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10259 ___ ___ Python-bugs

[issue6036] Clean up test_posixpath.py

2012-11-30 Thread Bruno Dupuis
Bruno Dupuis added the comment: Mark, correct, this test doesn't exist in 3.X branches. I updated the patch for 2.7. It is trivial, so if someone may merge it, we could close this bug (please, before next SCM switch :-) ) -- nosy: +loewis Added file: http://bugs.python.org/file28170

[issue2921] enable embedding: declare/#define only py* symbols in #includes

2012-11-30 Thread Bruno Dupuis
Changes by Bruno Dupuis bdup...@lisael.org: -- nosy: +bruno.dupuis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2921 ___ ___ Python-bugs-list

[issue7976] warnings should provide a public API for accessing its option parsing code

2012-11-30 Thread Bruno Dupuis
Bruno Dupuis added the comment: Changes made. I added the exception doc and some cosmetics -- Added file: http://bugs.python.org/file28173/warnings_opt_parse_API-5.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7976

[issue1075356] exceeding obscure weakproxy bug

2012-11-30 Thread Bruno Dupuis
Changes by Bruno Dupuis bdup...@lisael.org: -- nosy: +bruno.dupuis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1075356 ___ ___ Python-bugs-list

[issue7976] warnings should provide a public API for accessing its option parsing code

2012-11-30 Thread Bruno Dupuis
Bruno Dupuis added the comment: corrected, I changed the name of the function to parse_option, and I kept WarningsOptionParsingError as a name for the exception. These two sound good together. -- Added file: http://bugs.python.org/file28174/warnings_opt_parse_API-6.patch

[issue7976] warnings should provide a public API for accessing its option parsing code

2012-11-30 Thread Bruno Dupuis
Changes by Bruno Dupuis bdup...@lisael.org: Added file: http://bugs.python.org/file28175/warnings_opt_parse_API-7.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7976

[issue16588] gcc 4.7 ilegitimate unused-but-set warnings on Python/thread_pthread.h

2012-11-30 Thread Bruno Dupuis
New submission from Bruno Dupuis: Looks like #10951, but for another version of gcc. I get these warnings: In file included from Python/thread.c:86:0: Python/thread_pthread.h: In function ‘PyThread_free_lock’: Python/thread_pthread.h:304:17: attention : variable ‘error’ set but not used

[issue7976] warnings should provide a public API for accessing its option parsing code

2012-11-29 Thread Bruno Dupuis
Bruno Dupuis added the comment: Ok, changes made. I also updated the tests -- Added file: http://bugs.python.org/file28158/warnings_opt_parse_API-3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7976

[issue7976] warnings should provide a public API for accessing its option parsing code

2012-11-29 Thread Bruno Dupuis
Changes by Bruno Dupuis bdup...@lisael.org: -- hgrepos: +161 Added file: http://bugs.python.org/file28160/warnings_opt_parse_API-4.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7976

[issue16049] Create abstract base classes by inheritance rather than a direct invocation of __metaclass__

2012-11-29 Thread Bruno Dupuis
Bruno Dupuis added the comment: This solution hides the risk of metaclass conflicts, as the user did not explicitly set the metaclass. IMO, this risk should be clearly told in the Doc. -- nosy: +bruno.dupuis ___ Python tracker rep...@bugs.python.org

[issue6835] doctest problem with decorated function when decorator is defined in separate file

2012-11-29 Thread Bruno Dupuis
Changes by Bruno Dupuis bdup...@lisael.org: -- nosy: +bruno.dupuis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6835 ___ ___ Python-bugs-list

[issue7976] warnings should provide a public API for accessing its option parsing code

2012-11-28 Thread Bruno Dupuis
Bruno Dupuis added the comment: Patch attached. I just exposed _setoption() as process_option() so that the user can manage execptions as she wants but she has to make his own loop. `_OptionError` is exposed as `WarningsOptParsingError`. I'm not satisfied with this name as it is quite long

[issue7976] warnings should provide a public API for accessing its option parsing code

2012-11-28 Thread Bruno Dupuis
Bruno Dupuis added the comment: Thanks, I'll write the doc. Now, I'm not sure that keeping _OptionError as WarningsOptParsingError base class is a good idea. I can't see any use case to catch this exception outside the module and I'm quite sure nobody ever has. However, I tend to be over

[issue7976] warnings should provide a public API for accessing its option parsing code

2012-11-28 Thread Bruno Dupuis
Bruno Dupuis added the comment: I added the documentation with a recipe. -- Added file: http://bugs.python.org/file28154/warnings_opt_parse_API-2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7976

[issue7976] warnings should provide a public API for accessing its option parsing code

2012-11-28 Thread Bruno Dupuis
Bruno Dupuis added the comment: Éric, I saw the `review` link just after I submited the second patch, and I read your comments. I'll do the changes. Sorry, I still have to learn the tools and processes. -- ___ Python tracker rep...@bugs.python.org