Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
53b26549
Commit
53b26549
authored
Jan 17, 2016
by
Wenzel Jakob
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python 3.2 compatiblity (closes #56)
parent
ba0732e7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
39 deletions
+42
-39
example/example2.py
+2
-2
include/pybind11/common.h
+38
-35
include/pybind11/pytypes.h
+2
-2
No files found.
example/example2.py
View file @
53b26549
...
@@ -30,11 +30,11 @@ dict_result['key2'] = 'value2'
...
@@ -30,11 +30,11 @@ dict_result['key2'] = 'value2'
instance
.
print_dict_2
(
dict_result
)
instance
.
print_dict_2
(
dict_result
)
set_result
=
instance
.
get_set
()
set_result
=
instance
.
get_set
()
set_result
.
add
(
u
'key3'
)
set_result
.
add
(
'key3'
)
instance
.
print_set
(
set_result
)
instance
.
print_set
(
set_result
)
set_result
=
instance
.
get_set2
()
set_result
=
instance
.
get_set2
()
set_result
.
add
(
u
'key3'
)
set_result
.
add
(
'key3'
)
instance
.
print_set_2
(
set_result
)
instance
.
print_set_2
(
set_result
)
list_result
=
instance
.
get_list
()
list_result
=
instance
.
get_list
()
...
...
include/pybind11/common.h
View file @
53b26549
...
@@ -10,62 +10,65 @@
...
@@ -10,62 +10,65 @@
#pragma once
#pragma once
#if !defined(NAMESPACE_BEGIN)
#if !defined(NAMESPACE_BEGIN)
#define NAMESPACE_BEGIN(name) namespace name {
#
define NAMESPACE_BEGIN(name) namespace name {
#endif
#endif
#if !defined(NAMESPACE_END)
#if !defined(NAMESPACE_END)
#define NAMESPACE_END(name) }
#
define NAMESPACE_END(name) }
#endif
#endif
#if !defined(PYBIND11_EXPORT)
#if !defined(PYBIND11_EXPORT)
#if defined(WIN32) || defined(_WIN32)
#
if defined(WIN32) || defined(_WIN32)
#define PYBIND11_EXPORT __declspec(dllexport)
#
define PYBIND11_EXPORT __declspec(dllexport)
#else
#
else
#define PYBIND11_EXPORT __attribute__ ((visibility("default")))
#
define PYBIND11_EXPORT __attribute__ ((visibility("default")))
#endif
#
endif
#endif
#endif
#if defined(_MSC_VER)
#if defined(_MSC_VER)
#define PYBIND11_NOINLINE __declspec(noinline)
#
define PYBIND11_NOINLINE __declspec(noinline)
#else
#else
#define PYBIND11_NOINLINE __attribute__ ((noinline))
#
define PYBIND11_NOINLINE __attribute__ ((noinline))
#endif
#endif
#include <vector>
#include <string>
#include <stdexcept>
#include <unordered_set>
#include <unordered_map>
#include <memory>
/// Include Python header, disable linking to pythonX_d.lib on Windows in debug mode
/// Include Python header, disable linking to pythonX_d.lib on Windows in debug mode
#if defined(_MSC_VER)
#if defined(_MSC_VER)
#define HAVE_ROUND
#
define HAVE_ROUND
#pragma warning(push)
#
pragma warning(push)
#pragma warning(disable: 4510 4610 4512 4005)
#
pragma warning(disable: 4510 4610 4512 4005)
#if _DEBUG
#
if _DEBUG
#define _DEBUG_MARKER
#
define _DEBUG_MARKER
#undef _DEBUG
#
undef _DEBUG
#endif
#
endif
#endif
#endif
#include <Python.h>
#include <Python.h>
#include <frameobject.h>
#include <frameobject.h>
#ifdef isalnum
#ifdef isalnum
#undef isalnum
#
undef isalnum
#undef isalpha
#
undef isalpha
#undef islower
#
undef islower
#undef isspace
#
undef isspace
#undef isupper
#
undef isupper
#undef tolower
#
undef tolower
#undef toupper
#
undef toupper
#endif
#endif
#if defined(_MSC_VER)
#if defined(_MSC_VER)
#if defined(_DEBUG_MARKER)
#
if defined(_DEBUG_MARKER)
#define _DEBUG
#
define _DEBUG
#undef _DEBUG_MARKER
#
undef _DEBUG_MARKER
#endif
#endif
#pragma warning(pop)
#
pragma warning(pop)
#endif
#endif
#include <vector>
#include <string>
#include <stdexcept>
#include <unordered_set>
#include <unordered_map>
#include <memory>
#if PY_MAJOR_VERSION >= 3 /// Compatibility macros for various Python versions
#if PY_MAJOR_VERSION >= 3 /// Compatibility macros for various Python versions
#define PYBIND11_BYTES_CHECK PyBytes_Check
#define PYBIND11_BYTES_CHECK PyBytes_Check
#define PYBIND11_BYTES_FROM_STRING PyBytes_FromString
#define PYBIND11_BYTES_FROM_STRING PyBytes_FromString
...
...
include/pybind11/pytypes.h
View file @
53b26549
...
@@ -248,13 +248,13 @@ public:
...
@@ -248,13 +248,13 @@ public:
}
}
operator
std
::
string
()
const
{
operator
std
::
string
()
const
{
#if PY_MAJOR_VERSION >= 3
#if PY_MAJOR_VERSION >= 3
&& PY_MINOR_VERSION >= 3
return
PyUnicode_AsUTF8
(
m_ptr
);
return
PyUnicode_AsUTF8
(
m_ptr
);
#else
#else
object
temp
(
PyUnicode_AsUTF8String
(
m_ptr
),
false
);
object
temp
(
PyUnicode_AsUTF8String
(
m_ptr
),
false
);
if
(
temp
.
ptr
()
==
nullptr
)
if
(
temp
.
ptr
()
==
nullptr
)
pybind11_fail
(
"Unable to extract string contents!"
);
pybind11_fail
(
"Unable to extract string contents!"
);
return
P
yString_AsString
(
temp
.
ptr
());
return
P
YBIND11_BYTES_AS_STRING
(
temp
.
ptr
());
#endif
#endif
}
}
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment