Skip to content

Commit

Permalink
Merge pull request #320 from python-greenlet/issue308
Browse files Browse the repository at this point in the history
Internally define PY_SSIZE_T_CLEAN
  • Loading branch information
jamadden committed Oct 27, 2022
2 parents 3f67490 + 6c1162c commit e679a7d
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/greenlet/greenlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <exception>


#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "structmember.h" // PyMemberDef

Expand Down
1 change: 1 addition & 0 deletions src/greenlet/greenlet.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef Py_GREENLETOBJECT_H
#define Py_GREENLETOBJECT_H


#include <Python.h>

#ifdef __cplusplus
Expand Down
1 change: 1 addition & 0 deletions src/greenlet/greenlet_allocator.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef GREENLET_ALLOCATOR_HPP
#define GREENLET_ALLOCATOR_HPP

#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <memory>
#include "greenlet_compiler_compat.hpp"
Expand Down
1 change: 1 addition & 0 deletions src/greenlet/greenlet_cpython_compat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Helpers for compatibility with multiple versions of CPython.
*/

#define PY_SSIZE_T_CLEAN
#include "Python.h"

// These enable writing template functions or classes specialized
Expand Down
1 change: 1 addition & 0 deletions src/greenlet/greenlet_exceptions.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef GREENLET_EXCEPTIONS_HPP
#define GREENLET_EXCEPTIONS_HPP

#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <stdexcept>

Expand Down
3 changes: 2 additions & 1 deletion src/greenlet/greenlet_greenlet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* Declarations of the core data structures.
*/

#define PY_SSIZE_T_CLEAN
#include <Python.h>
//#include "greenlet_internal.hpp"

#include "greenlet_compiler_compat.hpp"
#include "greenlet_refs.hpp"
#include "greenlet_cpython_compat.hpp"
Expand Down
1 change: 1 addition & 0 deletions src/greenlet/greenlet_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* C++ templates and inline functions should go here.
*/
#define PY_SSIZE_T_CLEAN
#include "greenlet_compiler_compat.hpp"
#include "greenlet_cpython_compat.hpp"
#include "greenlet_exceptions.hpp"
Expand Down
5 changes: 3 additions & 2 deletions src/greenlet/greenlet_refs.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef GREENLET_REFS_HPP
#define GREENLET_REFS_HPP

#define PY_SSIZE_T_CLEAN
#include <Python.h>
//#include "greenlet_internal.hpp"
#include "greenlet_compiler_compat.hpp"
Expand All @@ -14,7 +15,7 @@ typedef struct _greenlet PyGreenlet;
extern PyTypeObject PyGreenlet_Type;


#ifndef NDEBUG
#ifdef GREENLET_USE_STDIO
#include <iostream>
using std::cerr;
using std::endl;
Expand Down Expand Up @@ -243,7 +244,7 @@ namespace greenlet {
}
};

#ifndef NDEBUG
#ifdef GREENLET_USE_STDIO
template<typename T, TypeChecker TC>
std::ostream& operator<<(std::ostream& os, const PyObjectPointer<T, TC>& s)
{
Expand Down

0 comments on commit e679a7d

Please sign in to comment.