Modify

Opened 9 years ago

Last modified 8 years ago

#2909 new Bugs

[Fix in git] Wrong type signatures?

Reported by: Haoyu Bai Owned by: troy d. straszheim
Milestone: Boost 1.39.0 Component: python USE GITHUB
Version: Boost 1.38.0 Severity: Problem
Keywords: Cc: divinekid@…

Description

In python/converter/builtin_converters.hpp, I found these lines:

BOOST_PYTHON_TO_PYTHON_BY_VALUE(signed BOOST_PYTHON_LONG_LONG, ::PyLong_FromLongLong(x), &PyInt_Type) BOOST_PYTHON_TO_PYTHON_BY_VALUE(unsigned BOOST_PYTHON_LONG_LONG, ::PyLong_FromUnsignedLongLong(x), &PyInt_Type)

and,

BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::wstring, ::PyUnicode_FromWideChar(x.data(),implicit_cast<ssize_t>(x.size())), &PyString_Type)

Seems it is a typo. Should the PyInt_Type be PyLong_Type, and the PyString_Type be PyUnicode_Type?

These macro argument is used for generate the return value of get_pytype(). And seems get_pytype() is only used to generate docstring. So there's accutally no problem caused by these.

But, should these be typo? If so, we'd better fix it.

Thanks!

Attachments (3)

typetypo.diff (1.6 KB) - added by Haoyu Bai 9 years ago.
Patch to fix the typo
typetypo.cpp (325 bytes) - added by Haoyu Bai 9 years ago.
Testcase showing the problem.
typetypo.py (305 bytes) - added by Haoyu Bai 9 years ago.
Testcase showing the problem.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 9 years ago by Haoyu Bai

Cc: divinekid@… added

comment:2 Changed 9 years ago by Dave Abrahams

The best way to know if these are bugs that need to be fixed is to produce test cases (a .cpp and a matching .py file—see this directory for examples) that currently fail and would stop failing if the fixes were made. Can you do that and post an attachment?

Thanks!

Changed 9 years ago by Haoyu Bai

Attachment: typetypo.diff added

Patch to fix the typo

Changed 9 years ago by Haoyu Bai

Attachment: typetypo.cpp added

Testcase showing the problem.

Changed 9 years ago by Haoyu Bai

Attachment: typetypo.py added

Testcase showing the problem.

comment:3 Changed 9 years ago by Haoyu Bai

Testcase and patch attached.

Without the patch, the test giving the following result:

Docstring say:  
return_longlong() -> int :

    C++ signature :
        long long return_longlong()
But actually type of return value is: <type 'long'>

Docstring say:  
return_wstring() -> str :

    C++ signature :
        std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > return_wstring()
But actually type of return value is: <type 'unicode'>

Notice the "return_longlong() -> int" and "return_wstring() -> str".

With the patch, the result seems correct:

Docstring say:  
return_longlong() -> long :

    C++ signature :
        long long return_longlong()
But actually type of return value is: <type 'long'>

Docstring say:  
return_wstring() -> unicode :

    C++ signature :
        std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > return_wstring()
But actually type of return value is: <type 'unicode'>

Also, this patch don't affect other test cases, as they are all passed. I think it is just related to the docstring and won't touch any other things.

comment:4 Changed 8 years ago by troy d. straszheim

Owner: changed from Dave Abrahams to troy d. straszheim

Looks like the fix made it to the trunk, but not the test, and I notice:

print return_string.doc

return_string() -> str :

C++ signature :

std::string return_string()

print return_wstring.doc

return_wstring() -> unicode :

C++ signature :

std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > return_wstring()

that that basic_string<wchar... should be simplified to std::wstring for readability. Working on it.

comment:5 Changed 8 years ago by troy d. straszheim

Summary: Wrong type signatures?[Fix in git] Wrong type signatures?

Fix here:

http://gitorious.org/~straszheim/boost/straszheim/commit/aeefdf7abca8c33c25a98a5f7fc78e4e888f9c94

also clean up printing of std::wstring as the gcc demangler was being messy about it.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain troy d. straszheim.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.