[issue17285] subprocess.check_output incorrectly state that output is always bytes

2013-02-24 Thread Baptiste Lepilleur
New submission from Baptiste Lepilleur: Documentation states: help( subprocess.check_output ) check_output(*popenargs, timeout=None, **kwargs) Run command with arguments and return its output as a byte string. But the most common usage is: subprocess.check_output( 'echo test', shell=True

[issue17286] Make subprocess handling text output with universal_newlines more obious

2013-02-24 Thread Baptiste Lepilleur
New submission from Baptiste Lepilleur: It tooks me a while to figure out that using universal_newlines was the solution to tell subprocess that I wanted text string output instead of byte string. A search on stackoverflow shows that this issue is common and the solution nearly unknown

How to derive from datetime.timezone class?

2011-11-10 Thread Baptiste Lepilleur
Hi, I want to sub-class the datetime.timezone class, but when I derive from datetime.timezone I get an error message TypeError: type 'datetime.timezone' is not an acceptable base type. Why do I get this error? Is there something specific to do to avoid it? Below is an example of code: Python

[issue11852] New QueueListener is unusable due to threading and queue import

2011-04-15 Thread Baptiste Lepilleur
New submission from Baptiste Lepilleur b...@users.sourceforge.net: How to reproduce: from logging.handlers import QueueListener from multiprocessing import Queue q = Queue(100) l = QueueListener(q) Traceback (most recent call last): File stdin, line 1, in module File C:\Python32\lib

[issue11852] New QueueListener is unusable due to threading and queue import

2011-04-15 Thread Baptiste Lepilleur
Baptiste Lepilleur b...@users.sourceforge.net added the comment: Forgot to give the precise python version: Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win32 -- ___ Python tracker rep...@bugs.python.org http

[issue11852] New QueueListener is unusable due to missing threading and queue import

2011-04-15 Thread Baptiste Lepilleur
Changes by Baptiste Lepilleur b...@users.sourceforge.net: -- title: New QueueListener is unusable due to threading and queue import - New QueueListener is unusable due to missing threading and queue import ___ Python tracker rep...@bugs.python.org

[issue10870] Last line of argparse code samples can not be read on Windows

2011-01-09 Thread Baptiste Lepilleur
New submission from Baptiste Lepilleur b...@users.sourceforge.net: When the code samples from the CHM documentation are displayed, if the lines are too long, a scroll bar is added at the bottom which prevents reading the last line of the code sample. Usually this can be worked-around

[issue10871] argparse example use file instead of open

2011-01-09 Thread Baptiste Lepilleur
New submission from Baptiste Lepilleur b...@users.sourceforge.net: In section 14.4.3.6. type of the argparse module, the following code sample is given: parser = argparse.ArgumentParser() parser.add_argument('foo', type=int) parser.add_argument('bar', type=file) parser.parse_args('2

How to port bytes formatting to Python 3.x ?

2011-01-01 Thread Baptiste Lepilleur
Hi, I'm trying to port a small library to Python 3.x, and I'm wondering what is the best way to port statements such as the one belows that are frequently found in network protocol implementation: headerparts = (%s:%s\n % (key, value) for key, value in headers.iteritems())

How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3?

2011-01-01 Thread Baptiste Lepilleur
Hi, I'm trying to port some network protocol library to Python 3.x, and it defines many bytes literals as plain string. How do you define bytes literals so that the library can be ported to Python 3.x using only 2to3? For example: In python 2.x, I need: self.buffer = '\n' In python 3.x,

Re: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3?

2011-01-01 Thread Baptiste Lepilleur
2011/1/1 Stefan Behnel stefan...@behnel.de Terry Reedy, 01.01.2011 11:08: On 1/1/2011 4:08 AM, Baptiste Lepilleur wrote: Is there a way to mark string literals so that 2to3 automatically prefixes them with 'b'? Is there a simpler trick? Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46

Re: How to port bytes formatting to Python 3.x ?

2011-01-01 Thread Baptiste Lepilleur
2011/1/1 Stefan Behnel stefan...@behnel.de Baptiste Lepilleur, 01.01.2011 10:01: Hi, I'm trying to port a small library to Python 3.x, and I'm wondering what is the best way to port statements such as the one belows that are frequently found in network protocol implementation

Change in scope of handled exception variable in Python 3?

2010-12-30 Thread Baptiste Lepilleur
Hi, I stumbled on a small bug with httplib2 that I reduced to the example below. It seems that with Python 3, when an exception is handled it unbound the previously declared local variable. This did not occurs with Python 2.5. It is a Python 3 feature? I did not find anything in the what's news,

Re: Why tarfile.TarFile.gzopen is not in the online documentation?

2010-02-26 Thread Baptiste Lepilleur
2010/2/24 Lars Gustäbel l...@gustaebel.de On Wed, Feb 24, 2010 at 09:37:19AM +0100, Baptiste Lepilleur wrote: I stumbled uppon this and find it somewhat odd: some class methods of TarFile and TarInfo do not appears in either the online documentation or search while they have a doc string

Why tarfile.TarFile.gzopen is not in the online documentation?

2010-02-24 Thread Baptiste Lepilleur
I stumbled uppon this and find it somewhat odd: some class methods of TarFile and TarInfo do not appears in either the online documentation or search while they have a doc string: http://docs.python.org/search.html?q=gzopen

What is the equivalent of chr(x) for bytes in python 3?

2009-12-26 Thread Baptiste Lepilleur
Hi, I'm looking for the equivalent of the built-in chr(x) function that would return a bytes type taking an integer as parameter. The easiest way I found to do this is the function below, but there must be some simpler way to do that and I must be overlooking something fairly obvious... def

Semantic of operations on a closed file object

2009-12-26 Thread Baptiste Lepilleur
Reading python io.IOBase class documentation, I'm kind of confused at the expected behavior of operation on a closed file object. The io.IOBase class doc says: Note that calling any method (even inquiries) on a closed stream is undefined. Implementations may raise

[issue7578] Behavio of operations on a closed file object is not documented correctly

2009-12-26 Thread Baptiste Lepilleur
New submission from Baptiste Lepilleur b...@users.sourceforge.net: The io.IOBase class doc says: Note that calling any method (even inquiries) on a closed stream is undefined. Implementations may raise IOError in this case. But the io.IOBase.close() method document says: Once the file is closed

[issue7578] Behavior of operations on a closed file object is not documented correctly

2009-12-26 Thread Baptiste Lepilleur
Changes by Baptiste Lepilleur b...@users.sourceforge.net: -- title: Behavio of operations on a closed file object is not documented correctly - Behavior of operations on a closed file object is not documented correctly ___ Python tracker rep

Re: Why the expression (1) is not an one-arity tuple, but int ?

2009-12-04 Thread Baptiste Lepilleur
By adding a before the closing brace of the tuple. Python allow this to disambiguate between braced expression and tuple type( (1,) ) type 'tuple' 2009/12/4 Петров Александр gmdi...@gmail.com How could I tell Python that (1) is not an integer, but an one-arity tuple ? Thank you,

Re: Why the expression (1) is not an one-arity tuple, but int ?

2009-12-04 Thread Baptiste Lepilleur
By adding a before the closing brace of the tucomma after 1. Python allow this to disambiguate between braced expression and tuple type( (1,) ) type 'tuple' 2009/12/4 Петров Александр gmdi...@gmail.com How could I tell Python that (1) is not an integer, but an one-arity tuple ? Thank

Re: Writing an emulator in python - implementation questions (for performance)

2009-11-15 Thread Baptiste Lepilleur
I think you can use python itself for pre-processing. Here is an (shortened) example from PyPy RPython paper: # operators: the docstrings contain the # symbol associated with each operator class Op_Add(BinaryExpr): ’+’ class Op_Sub(BinaryExpr): ’-’ # INIT-TIME only: build the table of #

[issue7287] import hook demo does not work

2009-11-08 Thread Baptiste Lepilleur
New submission from Baptiste Lepilleur b...@users.sourceforge.net: The import hook demo in the source directory Python-3.1.1\Demo\imputil\knee.py fails to run correctly: Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits

What is the correct way to port codecs.open to python 3.1?

2009-11-07 Thread Baptiste Lepilleur
After applying 2to3.py to port a 2.6 script to 3.1, I get the following error when running my script: File purekeyworddbtest.py, line 143, in __init__ f = codecs.open(EXCLUDED_KEYWORDS_FILE, 'rt', 'utf-8') File c:\Python31\lib\codecs.py, line 870, in open file = builtins.open(filename,

[issue7280] PCBuild instruction says to use nasmw.exe but it no longer exist

2009-11-07 Thread Baptiste Lepilleur
New submission from Baptiste Lepilleur b...@users.sourceforge.net: PCBuild requires nasmw.exe but it no longer exists in the latest version of nasm. I had to rename nasm.exe to nasmw.exe. Would be nice to add this to the readme to avoid confusion... -- components: Build files: nasm

Looking for a tool to checkfor python script backward compatibility

2009-07-12 Thread Baptiste Lepilleur
I'm looking for a tool that could be used in a pre-commit step to check that only features available in a old python version are used, say python 2.3 for example. Does any one know of one ? -- http://mail.python.org/mailman/listinfo/python-list

How to suppress UnicodeError exception when enabling httplib debug?

2006-08-06 Thread Baptiste Lepilleur
I activated httplib debug, and when trace are printed, a UnicodeError exception is thrown. I have already set sys.stdout to use utf-8 encoding (this removed the exception when *I* was printing unicode), but from the stacktrace below, the encoding seems to magically have switched to 'ascii'