[ python-Bugs-1418374 ] PyRun_SimpleString won't parse \\x

2006-01-30 Thread SourceForge.net
Bugs item #1418374, was opened at 2006-01-30 08:43
Message generated for change (Comment added) made by effbot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1418374&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: Parser/Compiler
Group: Python 2.4
>Status: Deleted
>Resolution: Invalid
Priority: 5
Submitted By: gnupun (gnupun)
Assigned to: Nobody/Anonymous (nobody)
Summary: PyRun_SimpleString won't parse \\x

Initial Comment:
I'm trying to use Python 2.4.2 from C on Win XP. 
The following line of C code generates an error:

test.c:
PyRun_SimpleString( "s = 'C:\\xyz'\n" );

Output:
ValueError: invalid \x escape


The error message only occurs if 'x' follows the 
slashes '\\x'. That is, no other letter causes this 
problem:

PyRun_SimpleString( "s = 'C:\\ayz'\n" );
PyRun_SimpleString( "s = 'C:\\yyz'\n" );

Using forward slashes also prevents the error:
PyRun_SimpleString( "s = "C:/xyz'\n" ); // ok


--

>Comment By: Fredrik Lundh (effbot)
Date: 2006-01-30 17:16

Message:
Logged In: YES 
user_id=38376

> The following line of C code generates an error

C uses the same escape rules as Python, so your first
test snippet looks like "C:\xyz" to Python.  which is
is an invalid string literal, just as the message says.

see the Python language reference to details on string
literal syntax.

--

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



[ python-Bugs-1419652 ] PyImport_AppendInittab stores pointer to parameter

2006-01-30 Thread SourceForge.net
Bugs item #1419652, was opened at 2006-01-31 03:19
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1419652&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: coder_5 (coder_5)
Assigned to: Nobody/Anonymous (nobody)
Summary: PyImport_AppendInittab stores pointer to parameter

Initial Comment:
signature is:

int PyImport_AppendInittab(char *name, void
(*initfunc)(void))

if the 'name' pointer is freed or overwritten directly
after the call to PyImport_AppendInittab, this call
returns true but fails making the module known, and the
interpreter crashes on PyFinalize();
this suggests that PyImport_AppendInittab stores the
name pointer and uses it later, after leaving this
function. this is undocumented and leads to crashes if
name is freed in the meantime. (a typical c problem)

this function is important to boost::python library to
extend python with c++.

workaround for c/c++ users:
-malloc a char* for the name,
-copy the modulename to name
-call PyImport_AppendInittab with this name
-DONT free name. (leaving a memory-leak)


btw, 'char *' should be 'const char*', but this applies
to most other Python API functions.

--

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



[ python-Bugs-1419989 ] class dictionary shortcircuits __getattr__

2006-01-30 Thread SourceForge.net
Bugs item #1419989, was opened at 2006-01-31 02:08
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1419989&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: Documentation
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Shaun Cutts (shauncutts)
Assigned to: Nobody/Anonymous (nobody)
Summary: class dictionary shortcircuits __getattr__

Initial Comment:
page 3.3.2 of Language Reference states:

"Note that at least for instance variables, you 
can fake total control by not inserting any values in 
the instance attribute dictionary (but instead 
inserting them in another object)."

A counterexample (doctest style):
-
>>> class Foo:
... bar = None
... def __getattr__( self, attr ):
... return 'boo'
...
>>> f = Foo()
>>> print "bar: ",f.bar
bar: None
--
'bar' in class dictionary (not just in instance 
dictionary) also causes __getattr__ not to be called.

BTW.. above in the doc, it says that __getattr__ 
called only if "normal methods" can't find attribute. 
So this would seem a documentation bug. 

However, right now at least, I would prefer if the 
instance dictionary alone were decisive.


--

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