Thread: [pygccxml-development] What am I doing wrong?
Brought to you by:
mbaas,
roman_yakovenko
From: Neal B. <ndb...@gm...> - 2006-04-17 21:12:00
Attachments:
hello_world.hpp
|
OK, back to my previous test. gccxml cvs is now updated so the problem I reported last week is fixed (thanks!) But still no luck. Any hints? (I have to say pyplusplus error messages could probably be more helpful) gccxml now runs without errors. But I get this: parsing files - started Reading project files: file by file Reading source file: [hello_world.hpp]. File has not been found in cache, parsing... Command line for GCC-XML: /usr/bin/gccxml -I"." -I"/usr/local/src/boost.cvs" "hello_world.hpp" -fxml="/tmp/tmp_TUhxm.xml" Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/tmp/python-W1AaN3.py", line 17, in ? mb = module_builder.module_builder_t( File "/usr/lib/python2.4/site-packages/pyplusplus/module_builder/builder.py", line 76, in __init__ , cache ) File "/usr/lib/python2.4/site-packages/pyplusplus/module_builder/builder.py", line 101, in __parse_declarations decls = reader.read_files( files, compilation_mode ) File "/usr/lib/python2.4/site-packages/pygccxml/parser/project_reader.py", line 149, in read_files return self.__parse_file_by_file(files) File "/usr/lib/python2.4/site-packages/pygccxml/parser/project_reader.py", line 172, in __parse_file_by_file decls = reader.read_file( header ) File "/usr/lib/python2.4/site-packages/pygccxml/parser/source_reader.py", line 164, in read_file raise error KeyError: 'name' This is from 'generate_code.py', which is this: import os #from environment import settings from pyplusplus import module_builder mb = module_builder.module_builder_t( files=['hello_world.hpp'],include_paths=['/usr/local/src/boost.cvs'],compilation_verbose=True ) Here is hello_world.hpp: |
From: Roman Y. <rom...@gm...> - 2006-04-17 21:41:34
|
On 4/18/06, Neal Becker <ndb...@gm...> wrote: > OK, back to my previous test. gccxml cvs is now updated so the problem I > reported last week is fixed (thanks!) > > But still no luck. Any hints? (I have to say pyplusplus error messages = could > probably be more helpful) Well, you are right messages could be much better. In most cases they are. In your case, I did not expect this code to fail. I guess this is because of your version of GCCXML. I will look at it. Thanks for bug reporting. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Neal B. <ndb...@gm...> - 2006-04-17 21:47:10
|
On Monday 17 April 2006 5:41 pm, Roman Yakovenko wrote: > On 4/18/06, Neal Becker <ndb...@gm...> wrote: > > OK, back to my previous test. gccxml cvs is now updated so the problem I > > reported last week is fixed (thanks!) > > > > But still no luck. Any hints? (I have to say pyplusplus error messages > > could probably be more helpful) > > Well, you are right messages could be much better. In most cases they are. > In your case, I did not expect this code to fail. I guess this is > because of your > version of GCCXML. I will look at it. > > Thanks for bug reporting. > > -- It is a problem in (Pdb) n > /usr/lib64/python2.4/site-packages/_xmlplus/sax/__init__.py(31)parse() -> parser.parse(filename_or_stream) (Pdb) n KeyError: <exceptions.KeyError instance at 0x2aaab05c7dd0> Something sax doesn't like. Not sure how to debug it, one thing does look strange in the xml file: <File id="f55" name="/usr/include/c++/4.1.0/cstring"/> <File id="f56" name="<internal>"/> <File id="f57" name="/usr/include/c++/4.1.0/ext/new_allocator.h"/> Anyway I put the xml here: http://nbecker.dyndns.org:8080/tmpTHoLWR.xml.gz |
From: Roman Y. <rom...@gm...> - 2006-04-18 08:11:06
Attachments:
scanner.py
|
Neal, I found the problem. Description: GCC-XML changed serialization of unnamed declarations ( enums + namespaces ) In previous version of GCC-XML, an element, that describes the declaration has attribute "name" with some content. Now it does not have this attribute. By the way, it was nothing wrong with SAX, but with my code. pygccxml uses SAX to parse XML files. It gaves huge speed improvement. The fix is simple: file pygccxml/parser/scanner.py search and replace next string attrs[ XML_AN_NAME ] with attrs.get( XML_AN_NAME, '' ) Or you can replace the file with one I attach with this mail. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Neal B. <ndb...@gm...> - 2006-04-18 10:56:56
|
On Tuesday 18 April 2006 4:10 am, Roman Yakovenko wrote: > Neal, I found the problem. > Description: GCC-XML changed serialization of unnamed declarations ( > enums + namespaces ) > In previous version of GCC-XML, an element, that describes the > declaration has attribute "name" with some content. Now it does not > have this attribute. > > By the way, it was nothing wrong with SAX, but with my code. pygccxml > uses SAX to > parse XML files. It gaves huge speed improvement. > > The fix is simple: > file pygccxml/parser/scanner.py > > search and replace next string > attrs[ XML_AN_NAME ] > with > attrs.get( XML_AN_NAME, '' ) > > Or you can replace the file with one I attach with this mail. > Thanks! I replaced scanner.py in pygccxml source, ran python setup.py build + install, but the same problem is still there. I confirmed that scanner.py is updated. parsing files - started Reading project files: file by file Reading source file: [hello_world.hpp]. File has not been found in cache, parsing... Command line for GCC-XML: /usr/bin/gccxml -I"." -I"/usr/local/src/boost.cvs" "hello_world.hpp" -fxml="/tmp/tmpDRYXEY.xml" Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/tmp/python-4tAz49.py", line 17, in ? mb = module_builder.module_builder_t( File "/usr/lib/python2.4/site-packages/pyplusplus/module_builder/builder.py", line 76, in __init__ , cache ) File "/usr/lib/python2.4/site-packages/pyplusplus/module_builder/builder.py", line 101, in __parse_declarations decls = reader.read_files( files, compilation_mode ) File "/usr/lib/python2.4/site-packages/pygccxml/parser/project_reader.py", line 149, in read_files return self.__parse_file_by_file(files) File "/usr/lib/python2.4/site-packages/pygccxml/parser/project_reader.py", line 172, in __parse_file_by_file decls = reader.read_file( header ) File "/usr/lib/python2.4/site-packages/pygccxml/parser/source_reader.py", line 164, in read_file raise error KeyError: 'name' |
From: Roman Y. <rom...@gm...> - 2006-04-18 11:14:00
|
On 4/18/06, Neal Becker <ndb...@gm...> wrote: > > I replaced scanner.py in pygccxml source, ran python setup.py build + ins= tall, > but the same problem is still there. I confirmed that scanner.py is upda= ted. > parsing files - started I run all tests I have. Can you run unittests? You have unittests dir. Within this directory there is file "autoconfig.py" Please adjust the settings and run next command: python test_all.py Only 2 tests should fail. Also can you debug the problem? Thanks -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Roman Y. <rom...@gm...> - 2006-04-18 12:48:38
|
Neal, I found another set of problems with GCCXML. I will fix pygccxml/pyplusplus and will send the patches to the list. Sorry for inconvenience -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Roman Y. <rom...@gm...> - 2006-04-18 18:32:57
Attachments:
scanner.py
linker.py
|
I hope this time I provides almost complete fix for the bug. Description: First of all I missed some index operator on attrs - in Python function, that read C++ function declaration. So what happened? For some constructors GCC-XML does not generates "name" attribute. I guess he does it for compiler generated constructors or may be for something else. I still need to find out. Until now about the problem. Now about a solution= . The solution consist from 2 parts: 1. to modify scanner_t.__read_calldef function: calldef.name =3D attrs[ XML_AN_NAME ] =3D=3D> calldef.name =3D attrs.get(XML_AN_NAME, '') 2. to modify linker_t.visit_class member function. In this function, for unnamed constructors pygccxml will assign class name. So why almost? Because I want to play on safe-side :-) Neal, please try it and report the problems. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Neal B. <ndb...@gm...> - 2006-04-18 18:56:55
|
On Tuesday 18 April 2006 2:32 pm, Roman Yakovenko wrote: > I hope this time I provides almost complete fix for the bug. > Description: > > First of all I missed some index operator on attrs - in Python > function, that read C++ function > declaration. > So what happened? For some constructors GCC-XML does not generates > "name" attribute. > I guess he does it for compiler generated constructors or may be for > something else. > I still need to find out. Until now about the problem. Now about a > solution. > > The solution consist from 2 parts: > 1. to modify scanner_t.__read_calldef function: > calldef.name = attrs[ XML_AN_NAME ] ==> calldef.name = > attrs.get(XML_AN_NAME, '') > 2. to modify linker_t.visit_class member function. In this function, > for unnamed constructors > pygccxml will assign class name. > > So why almost? Because I want to play on safe-side :-) > > Neal, please try it and report the problems. > Thanks! At least the previous test now runs to completion. Now on to bigger tests... |