Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
40561f6a
Commit
40561f6a
authored
7 years ago
by
Pospelov, Gennady
Browse files
Options
Downloads
Patches
Plain Diff
Fix for Python3 in python embedded functional tests
parent
88733beb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tests/Functional/Python/PyEmbedded/TestCases.cpp
+22
-1
22 additions, 1 deletion
Tests/Functional/Python/PyEmbedded/TestCases.cpp
with
22 additions
and
1 deletion
Tests/Functional/Python/PyEmbedded/TestCases.cpp
+
22
−
1
View file @
40561f6a
...
@@ -21,6 +21,27 @@
...
@@ -21,6 +21,27 @@
//! Comparing results of GetVersionNumber() function obtained in "embedded" and "native C++" ways.
//! Comparing results of GetVersionNumber() function obtained in "embedded" and "native C++" ways.
#if PY_MAJOR_VERSION >= 3
#define PyString_FromString PyUnicode_FromString
#define PyString_AsString PyBytes_AsString
#endif
namespace
{
const
char
*
asString
(
PyObject
*
object
)
{
#if PY_MAJOR_VERSION >= 3
PyObject
*
pyStr
=
PyUnicode_AsEncodedString
(
object
,
"utf-8"
,
"Error ~"
);
return
PyBytes_AsString
(
pyStr
);
#else
return
PyString_AsString
(
object
);
#endif
}
}
bool
FunctionCall
::
runTest
()
bool
FunctionCall
::
runTest
()
{
{
Py_Initialize
();
Py_Initialize
();
...
@@ -49,7 +70,7 @@ bool FunctionCall::runTest()
...
@@ -49,7 +70,7 @@ bool FunctionCall::runTest()
if
(
!
result
)
if
(
!
result
)
throw
std
::
runtime_error
(
"Error while calling function"
);
throw
std
::
runtime_error
(
"Error while calling function"
);
char
*
cstr
=
PyString_A
sString
(
result
);
const
char
*
cstr
=
a
sString
(
result
);
if
(
!
cstr
)
if
(
!
cstr
)
throw
std
::
runtime_error
(
"Error in return type"
);
throw
std
::
runtime_error
(
"Error in return type"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment