[ python-Bugs-1346547 ] _subprocess.c calls PyInt_AsLong without error checking

2005-11-12 Thread SourceForge.net
Bugs item #1346547, was opened at 2005-11-03 03:34
Message generated for change (Comment added) made by effbot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1346547&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Windows
Group: Python 2.4
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Luke (luked)
Assigned to: Fredrik Lundh (effbot)
Summary: _subprocess.c calls PyInt_AsLong without error checking

Initial Comment:
_subprocess.c calls PyInt_AsLong without checking
whether the conversion produced an error.
This bug can cause an error to be reported at the wrong
point, eg:

Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for
more information.
>>> import subprocess
>>> si = subprocess.STARTUPINFO()
>>> si.wShowWindow = 2**65
>>> obj = subprocess.Popen('notepad.exe', startupinfo=si)
>>> 1+1
OverflowError: long int too large to convert to int
>>>

--

>Comment By: Fredrik Lundh (effbot)
Date: 2005-11-12 11:28

Message:
Logged In: YES 
user_id=38376

Fixed along with #1351997.

--

Comment By: Fredrik Lundh (effbot)
Date: 2005-11-10 23:43

Message:
Logged In: YES 
user_id=38376

I've added a fix to the subprocess patch over at
http://www.python.org/sf/1351997

--

Comment By: Neal Norwitz (nnorwitz)
Date: 2005-11-03 06:20

Message:
Logged In: YES 
user_id=33168

This code (for startupinfo) is only valid on Windows.  The
problem seems to be at lines 379 and 380 in
PC/_subprocess.c.  I'll let someone who can test this one
take care of it.  The return result from getint() needs to
be checked.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1346547&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1349316 ] xmlrpclib does not use http proxy

2005-11-12 Thread SourceForge.net
Bugs item #1349316, was opened at 2005-11-06 03:07
Message generated for change (Comment added) made by effbot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1349316&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: greatred (greatred)
Assigned to: Nobody/Anonymous (nobody)
Summary: xmlrpclib does not use http proxy

Initial Comment:
The xmlrpclib class ServerProxy does not seem to be
able to make use of a HTTP proxy. This makes it
unusable behind a firewall where the proxy is the only
access to the destination server.

--

>Comment By: Fredrik Lundh (effbot)
Date: 2005-11-12 11:32

Message:
Logged In: YES 
user_id=38376

To handle this, you can use a custom transport. Here's an
example:

http://lowlife.jp/nobonobo/wiki/xmlrpcwithproxy.html

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1349316&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1316069 ] gzip.GzipFile.seek missing second argument

2005-11-12 Thread SourceForge.net
Bugs item #1316069, was opened at 2005-10-07 21:34
Message generated for change (Comment added) made by effbot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1316069&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Extension Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Neil Schemenauer (nascheme)
Assigned to: Nobody/Anonymous (nobody)
Summary: gzip.GzipFile.seek missing second argument

Initial Comment:
It would nice if GzipFile.seek matched file.seek and
BZ2File.seek and took a second argument.

--

>Comment By: Fredrik Lundh (effbot)
Date: 2005-11-12 11:57

Message:
Logged In: YES 
user_id=38376

I've posted a trivial patch over at

www.python.org/sf/1355023 

(can patches be attached to bugs, or do we always want them
over at the patch tracker?)

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1316069&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1296433 ] expat crash python

2005-11-12 Thread SourceForge.net
Bugs item #1296433, was opened at 2005-09-20 16:10
Message generated for change (Comment added) made by effbot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1296433&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: XML
Group: Python 2.4
Status: Open
Resolution: None
Priority: 6
Submitted By: Mike Rozhnov (rozhnov)
Assigned to: Nobody/Anonymous (nobody)
Summary: expat crash python

Initial Comment:
This simple script crash python.
Parsing of commented xml string work good.
(i.e. raised exception not crash python)
Buffer overflow during convertion to unicode?

Tested on Win XP and linux with kernel 2.4 with same
results.

--

>Comment By: Fredrik Lundh (effbot)
Date: 2005-11-12 12:05

Message:
Logged In: YES 
user_id=38376

Works for me under 2.3.2 (with expat 1.95.6) and 2.4.1 (with
expat 1.95.8).

Try upgrading your expat and see if the problem goes away.

--

Comment By: Neal Norwitz (nnorwitz)
Date: 2005-09-22 23:54

Message:
Logged In: YES 
user_id=33168

I can reproduce on Linux with current CVS and expat
1.95.5-2.  Note the size of the data only needs to be
greater than 1024.

xml = "%s" %
('a' * 1025)

I am not certain this problem is specific to Python.  It
might be down in expat only.  Need to investigate further.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1296433&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1353504 ] Python drops core when stdin is bogus

2005-11-12 Thread SourceForge.net
Bugs item #1353504, was opened at 2005-11-10 16:16
Message generated for change (Comment added) made by montanaro
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1353504&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: None
Status: Open
Resolution: Works For Me
Priority: 5
Submitted By: Skip Montanaro (montanaro)
Assigned to: Skip Montanaro (montanaro)
Summary: Python drops core when stdin is bogus

Initial Comment:
Someone here at work had the bright idea to execute a
Python
script from a Solaris 10 ~/.dtprofile file. 
Apparently, at the time
that script is run stdin is bogus.  Python core dumps
with this
gdb backtrace:

#0  0x0807d290 in PyDict_SetItem (op=0x815b79c,
key=0x8163f20, value=0x0)
at ../Objects/dictobject.c:549
#1  0x0807e0f7 in PyDict_SetItemString (v=0x815b79c,
key=0x8118df2 "stdin",
item=0x0) at ../Objects/dictobject.c:1988
#2  0x080e0d03 in _PySys_Init () at
../Python/sysmodule.c:977
#3  0x080ddfdb in Py_InitializeEx (install_sigs=1) at
../Python/pythonrun.c:190
#4  0x080dfa89 in Py_Initialize () at
../Python/pythonrun.c:283
#5  0x0805cd55 in Py_Main (argc=3, argv=0x8047c08) at
../Modules/main.c:418
#6  0x0805ca13 in main (argc=3, argv=0x8047c08) at
../Modules/python.c:23

(This is from 2.4.2, but it also happens in 2.3.4.)

Looking at the code in _PySys_Init it calls

sysin = PyFile_FromFile(stdin, "", "r", NULL);

which returns NULL.  In PyFile_FromFile it creates a new
PyFileObject, then initializes it by calling a static
function,
fill_file_fields.  This apparently fails, causing a NULL
pointer return.  Back in _PySys_Init it checks
PyErr_Occurred,
but fill_file_fields never raised an except.  The NULL
pointer
is passed to PyDict_SetItemString and havoc ensues.

I haven't checked CVS, but 2.4 (and probably 2.3) should be
fixed.  I suggest raising an IOError in
fill_file_fields instead
of just setting f to NULL and returning it.


--

>Comment By: Skip Montanaro (montanaro)
Date: 2005-11-12 07:18

Message:
Logged In: YES 
user_id=44345

Thanks Neal.  I'll check it out at work next week.


--

Comment By: Neal Norwitz (nnorwitz)
Date: 2005-11-11 01:24

Message:
Logged In: YES 
user_id=33168

This should be fixed in 2.4.3 and CVS (2.3.5 is probably
affected too).  I remember dealing with directories
specifically.  Checkout the current sysmodule.c.  Here's the
checkin:  

r39652 | nnorwitz | 2005-10-02 18:03:46 -0700 (Sun, 02 Oct
2005) | 5 lines

SF bug #887946.

Let me know if this bug is different and the patch doesn't
solve the problem.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1353504&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1343671 ] Broken docs for os.removedirs

2005-11-12 Thread SourceForge.net
Bugs item #1343671, was opened at 2005-10-31 12:30
Message generated for change (Comment added) made by effbot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1343671&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: David Kågedal (d_kagedal)
Assigned to: Nobody/Anonymous (nobody)
Summary: Broken docs for os.removedirs

Initial Comment:
The documentation for the os.removedirs function is
seriously broken.  This is from the library reference:

"removedirs(path)
Removes directories recursively. Works like rmdir()
except that, if the leaf directory is successfully
removed, directories corresponding to rightmost path
segments will be pruned way until either the whole path
is consumed or an error is raised (which is ignored,
because it generally means that a parent directory is
not empty). Throws an error exception if the leaf
directory could not be successfully removed. New in
version 1.5.2."

The first sentence is the only part that makes any
sense. This shorter version contains as much
information and less misinformation"

"removedirs(path)
   Removes a directory and everything in it
recursively. If a file couldn't be removed, the removal
is aborted and you might get an exception if you're lucky."

The doc string you get when you type
"help(os.removedirs)" is different from the one in the
library reference, but equally broken.

--

>Comment By: Fredrik Lundh (effbot)
Date: 2005-11-12 16:49

Message:
Logged In: YES 
user_id=38376

Are you sure you understand how the function works?

Given "spam/egg/bacon", it first attempts to do an rmdir on
spam/egg/bacon.  If that fails, the function raises an
exception.  Otherwise, it proceeds to rmdir spam/egg and
spam. Errors during the latter stage are ignored.

If you want to remove directories whether they're empty or
not, use shutil.rmtree.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1343671&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1343671 ] Broken docs for os.removedirs

2005-11-12 Thread SourceForge.net
Bugs item #1343671, was opened at 2005-10-31 12:30
Message generated for change (Comment added) made by effbot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1343671&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: David Kågedal (d_kagedal)
Assigned to: Nobody/Anonymous (nobody)
Summary: Broken docs for os.removedirs

Initial Comment:
The documentation for the os.removedirs function is
seriously broken.  This is from the library reference:

"removedirs(path)
Removes directories recursively. Works like rmdir()
except that, if the leaf directory is successfully
removed, directories corresponding to rightmost path
segments will be pruned way until either the whole path
is consumed or an error is raised (which is ignored,
because it generally means that a parent directory is
not empty). Throws an error exception if the leaf
directory could not be successfully removed. New in
version 1.5.2."

The first sentence is the only part that makes any
sense. This shorter version contains as much
information and less misinformation"

"removedirs(path)
   Removes a directory and everything in it
recursively. If a file couldn't be removed, the removal
is aborted and you might get an exception if you're lucky."

The doc string you get when you type
"help(os.removedirs)" is different from the one in the
library reference, but equally broken.

--

>Comment By: Fredrik Lundh (effbot)
Date: 2005-11-12 16:54

Message:
Logged In: YES 
user_id=38376

(I've changed the docstring from "remove a leaf directory and
empty all intermediate ones" to "remove a leaf directory and
all empty intermediate ones".  both the docstring and the docs
could need some clarification, but the text you propose is not
really an improvement...)

--

Comment By: Fredrik Lundh (effbot)
Date: 2005-11-12 16:49

Message:
Logged In: YES 
user_id=38376

Are you sure you understand how the function works?

Given "spam/egg/bacon", it first attempts to do an rmdir on
spam/egg/bacon.  If that fails, the function raises an
exception.  Otherwise, it proceeds to rmdir spam/egg and
spam. Errors during the latter stage are ignored.

If you want to remove directories whether they're empty or
not, use shutil.rmtree.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1343671&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1261714 ] precompiled code and nameError.

2005-11-12 Thread SourceForge.net
Bugs item #1261714, was opened at 2005-08-17 08:50
Message generated for change (Comment added) made by effbot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1261714&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Vladimir Menshakov (megath)
Assigned to: Nobody/Anonymous (nobody)
Summary: precompiled code and nameError.

Initial Comment:
i experienced problem with call'ing python unmarshalled
and eval'ed code. 

similar problem described in mailing list, but
unfortunately has not got any solution or work-around. 
http://mail.python.org/pipermail/c++-sig/2003-October/006094.html

actually I have code like this: 
-
import m

class A:
  def do(self): 
print m.User().GetName()

test.py
a = A() 
a.do()

running script from python works perfectly. but when I
call 'do' from c++ code I get following error : 
PyObject_CallMethod: exceptions.NameError:global name
'm' is not defined

I checked locals dictionary, it contains missing name
('m'). 


--

>Comment By: Fredrik Lundh (effbot)
Date: 2005-11-12 17:43

Message:
Logged In: YES 
user_id=38376

How do you call "do" from your C++ code?

"m" isn't a local variable, so what you stuff into the
locals directory doesn't matter; the important thing is that
the module associated with the function
(A.do.im_func.func_globals) contains the right thing.

--

Comment By: Neal Norwitz (nnorwitz)
Date: 2005-09-30 08:30

Message:
Logged In: YES 
user_id=33168

Can you provide the c++ code?  Thanks.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1261714&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1177811 ] Exec Inside A Function

2005-11-12 Thread SourceForge.net
Bugs item #1177811, was opened at 2005-04-06 16:30
Message generated for change (Comment added) made by effbot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1177811&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Andrew Wilkinson (andrew_j_w)
Assigned to: Nobody/Anonymous (nobody)
Summary: Exec Inside A Function

Initial Comment:
When 'exec'ing code that creates a function inside a function the 
defined function (fact in the example below) is created with the 
module level namespace as it's parent scope. 
 
The following should return 2 however it raises a NameError as fact 
is not defined. 
 
def f(): 
    exec """ 
def fact(x): 
    if x==1: 
        return 1 
    else: 
        return x*fact(x-1) 
""" 
    return fact 
 
f()(2) 
 
If you run following code... 
 
def f(): 
    exec """ 
def fact(x): 
    if x==1: 
        return 1 
    else: 
        return x*fact(x-1) 
""" in locals() 
    return fact 
 
... it works as expected. 
 
The documentation states that "In all cases, if the optional parts 
are omitted, the code is executed in the current scope." That is 
clearly not the case here as the 'fact' function is set with the 
module level scope as it's parent scope. 
 
It would appear to me that either this a documentation bug or a 
flaw in exec. I sincerely hope this a bug in exec and not the 
desired behaviour as it doesn't make any sense to me... 
 

--

>Comment By: Fredrik Lundh (effbot)
Date: 2005-11-12 17:59

Message:
Logged In: YES 
user_id=38376

As described in the language reference, scope analysis is
done statically, during compilation. If the compiler cannot
see your innermost function (because you've hidden it inside
a string literal), it obviously cannot take any variables in
there into account when generating code for the outer scopes.

(I sincerely hope that this is a contrived example, and that
you're not trying to use exec in this way in real code.
Python might be a highly dynamic language, but it's not this
dynamic.)

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1177811&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Feature Requests-1351692 ] Switch to make pprint.pprint display ints and longs in hex

2005-11-12 Thread SourceForge.net
Feature Requests item #1351692, was opened at 2005-11-08 22:29
Message generated for change (Comment added) made by doerwalter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1351692&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Mark Hirota (markhirota)
Assigned to: Nobody/Anonymous (nobody)
Summary: Switch to make pprint.pprint display ints and longs in hex

Initial Comment:
It would be nice to have some sort of switch or hook to 
allow 'pretty-printing' of integers and long integers in 
hexidecimal. So, for example:

>>> import pprint
>>> pprint.pprint(range(10)) # instead of this:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> pprint.hexint = True
>>> pprint.pprint(range(10)) # you would get this:
[0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9]
>>> pprint.pprint(range(0x1,0x10010)) # 
and this:
[0x1L,
 0x10001L,
 0x10002L,
 0x10003L,
 0x10004L,
 0x10005L,
 0x10006L,
 0x10007L,
 0x10008L,
 0x10009L,
 0x1000AL,
 0x1000BL,
 0x1000CL,
 0x1000DL,
 0x1000EL,
 0x1000FL]
>>>

Thanks,
--MH

--

>Comment By: Walter Dörwald (doerwalter)
Date: 2005-11-12 20:29

Message:
Logged In: YES 
user_id=89016

I think it's more of a limitation. I seems to me the main
focus in implementing pprint was speed not extensibility.
The code uses every trick in the book (e.g. turning globals
and builtins into locals, using bound methods etc.). I think
it was never ment to do anything other than what repr()
does, but with better formatting. However IMHO making pprint
extensible would be a worthwile project.

--

Comment By: Mark Hirota (markhirota)
Date: 2005-11-11 18:47

Message:
Logged In: YES 
user_id=1375527

Is this bypassing considered a limitation or a bug?  I am, 
however, able to workaround the issue by setting the 
width=1: "mpp = MyPrettyPrinter(1,1)" -- it just means that 
instead of:

>>> mpp.pprint(range(10))
[0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9]

I get instead:

>>> mpp.pprint(range(10))
[0x0,
 0x1,
 0x2,
 0x3,
 0x4,
 0x5,
 0x6,
 0x7,
 0x8,
 0x9]

...which is OK for my uses.  Thanks!

--

Comment By: Walter Dörwald (doerwalter)
Date: 2005-11-10 23:56

Message:
Logged In: YES 
user_id=89016

In theory this should be possible by subclassing
pprint.PrettyPrinter and overwritting the format method:

import pprint

class MyPrettyPrinter(pprint.PrettyPrinter):
  def format(self, object, context, maxlevels, level):
if isinstance(object, int):
  return hex(object), True, False
else:
  return pprint.PrettyPrinter.format(self, object,
context, maxlevels, level)

mpp = MyPrettyPrinter()
mpp.pprint(range(50))

This doesn't work reliable though: When the string is short
enough, format() seems to be bypassed and repr() is called
directly.


--

Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-11-09 22:45

Message:
Logged In: YES 
user_id=1188172

Moving to Feature Requests.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1351692&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Feature Requests-1351692 ] Switch to make pprint.pprint display ints and longs in hex

2005-11-12 Thread SourceForge.net
Feature Requests item #1351692, was opened at 2005-11-08 16:29
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1351692&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Mark Hirota (markhirota)
Assigned to: Nobody/Anonymous (nobody)
Summary: Switch to make pprint.pprint display ints and longs in hex

Initial Comment:
It would be nice to have some sort of switch or hook to 
allow 'pretty-printing' of integers and long integers in 
hexidecimal. So, for example:

>>> import pprint
>>> pprint.pprint(range(10)) # instead of this:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> pprint.hexint = True
>>> pprint.pprint(range(10)) # you would get this:
[0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9]
>>> pprint.pprint(range(0x1,0x10010)) # 
and this:
[0x1L,
 0x10001L,
 0x10002L,
 0x10003L,
 0x10004L,
 0x10005L,
 0x10006L,
 0x10007L,
 0x10008L,
 0x10009L,
 0x1000AL,
 0x1000BL,
 0x1000CL,
 0x1000DL,
 0x1000EL,
 0x1000FL]
>>>

Thanks,
--MH

--

>Comment By: Raymond Hettinger (rhettinger)
Date: 2005-11-12 15:02

Message:
Logged In: YES 
user_id=80475

IMO, such a rewrite would expose too many of pprint's
internals and make the module harder to
use/understand/maintain.  Wouldn't it be better to stick
with the usual idiom for controlling the repr() formatting
of specific types by using a class wrapper:

>>> from pprint import pprint
>>> class Int(int):
def __repr__(self):
return hex(self)

>>> pprint([Int(x) for x in range(0x1000,0x1010)])
[0x1000,
 0x1001,
 0x1002,
 0x1003,
 0x1004,
 0x1005,
 0x1006,
 0x1007,
 0x1008,
 0x1009,
 0x100a,
 0x100b,
 0x100c,
 0x100d,
 0x100e,
 0x100f]

--

Comment By: Walter Dörwald (doerwalter)
Date: 2005-11-12 14:29

Message:
Logged In: YES 
user_id=89016

I think it's more of a limitation. I seems to me the main
focus in implementing pprint was speed not extensibility.
The code uses every trick in the book (e.g. turning globals
and builtins into locals, using bound methods etc.). I think
it was never ment to do anything other than what repr()
does, but with better formatting. However IMHO making pprint
extensible would be a worthwile project.

--

Comment By: Mark Hirota (markhirota)
Date: 2005-11-11 12:47

Message:
Logged In: YES 
user_id=1375527

Is this bypassing considered a limitation or a bug?  I am, 
however, able to workaround the issue by setting the 
width=1: "mpp = MyPrettyPrinter(1,1)" -- it just means that 
instead of:

>>> mpp.pprint(range(10))
[0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9]

I get instead:

>>> mpp.pprint(range(10))
[0x0,
 0x1,
 0x2,
 0x3,
 0x4,
 0x5,
 0x6,
 0x7,
 0x8,
 0x9]

...which is OK for my uses.  Thanks!

--

Comment By: Walter Dörwald (doerwalter)
Date: 2005-11-10 17:56

Message:
Logged In: YES 
user_id=89016

In theory this should be possible by subclassing
pprint.PrettyPrinter and overwritting the format method:

import pprint

class MyPrettyPrinter(pprint.PrettyPrinter):
  def format(self, object, context, maxlevels, level):
if isinstance(object, int):
  return hex(object), True, False
else:
  return pprint.PrettyPrinter.format(self, object,
context, maxlevels, level)

mpp = MyPrettyPrinter()
mpp.pprint(range(50))

This doesn't work reliable though: When the string is short
enough, format() seems to be bypassed and repr() is called
directly.


--

Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-11-09 16:45

Message:
Logged In: YES 
user_id=1188172

Moving to Feature Requests.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1351692&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1092701 ] os.remove fails on win32 with read-only file

2005-11-12 Thread SourceForge.net
Bugs item #1092701, was opened at 2004-12-29 15:30
Message generated for change (Settings changed) made by effbot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1092701&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.4
>Status: Closed
>Resolution: Wont Fix
Priority: 3
Submitted By: Joshua Weage (jpweage)
Assigned to: Nobody/Anonymous (nobody)
Summary: os.remove fails on win32 with read-only file

Initial Comment:
On Windows XP SP2 and Python 2.3.3 or 2.4 a call to
os.remove returns Errno 13 permission denied on a
read-only file.  On linux, python will delete a
read-only file.



--

>Comment By: Fredrik Lundh (effbot)
Date: 2005-11-12 21:05

Message:
Logged In: YES 
user_id=38376

No followups in over 6 months. Closing.

--

Comment By: Fredrik Lundh (effbot)
Date: 2005-02-14 12:31

Message:
Logged In: YES 
user_id=38376

This is a platform issue; Windows associates delete privileges 
with the file, Unix with the directory.  I doubt it's a good idea 
to "fix" Python's remove by making it incompatible with the C 
library's implementation.

(on the C level, unlink() is the same thing as remove(), btw).


--

Comment By: Robert Brewer (aminusfu)
Date: 2005-01-01 10:13

Message:
Logged In: YES 
user_id=967320

Yup. I can reproduce that on Win2k.

Seems posixmodule.c uses _unlink, _wunlink, which are
documented at MS as failing on readonly:

"Each of these functions returns 0 if successful. Otherwise,
the function returns –1 and sets errno to EACCES, which
means the path specifies a read-only file, or to ENOENT,
which means the file or path is not found or the path
specified a directory."

Seems others have "fixed" it by just changing the mode and
trying again:
http://sources.redhat.com/ml/cygwin/2001-05/msg01209.html
https://www.cvshome.org/cyclic/cvs/unoff-watcom.txt


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1092701&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1296433 ] expat crash python

2005-11-12 Thread SourceForge.net
Bugs item #1296433, was opened at 2005-09-20 07:10
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1296433&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: XML
Group: Python 2.4
Status: Open
Resolution: None
Priority: 6
Submitted By: Mike Rozhnov (rozhnov)
Assigned to: Nobody/Anonymous (nobody)
Summary: expat crash python

Initial Comment:
This simple script crash python.
Parsing of commented xml string work good.
(i.e. raised exception not crash python)
Buffer overflow during convertion to unicode?

Tested on Win XP and linux with kernel 2.4 with same
results.

--

>Comment By: Neal Norwitz (nnorwitz)
Date: 2005-11-12 12:53

Message:
Logged In: YES 
user_id=33168

I had recently upgraded to expat 1.95.8, so I was hopeful. 
But it still crashed for me on linux.  

I did get a better stack trace which allowed me to come up
with a patch that solves the problem and passes all the
tests.  The patch seems a bit odd and I think there might be
another problem going on here.  It would be great if someone
more familiar with xmlparse could take a look at the patch
and figure out if it's right or not.

--

Comment By: Fredrik Lundh (effbot)
Date: 2005-11-12 03:05

Message:
Logged In: YES 
user_id=38376

Works for me under 2.3.2 (with expat 1.95.6) and 2.4.1 (with
expat 1.95.8).

Try upgrading your expat and see if the problem goes away.

--

Comment By: Neal Norwitz (nnorwitz)
Date: 2005-09-22 14:54

Message:
Logged In: YES 
user_id=33168

I can reproduce on Linux with current CVS and expat
1.95.5-2.  Note the size of the data only needs to be
greater than 1024.

xml = "%s" %
('a' * 1025)

I am not certain this problem is specific to Python.  It
might be down in expat only.  Need to investigate further.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1296433&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com