Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 2.4 compatibility #1

Merged
merged 1 commit into from Jul 1, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions python/decoder.c
Expand Up @@ -3,6 +3,7 @@
#include <lwpb/lwpb.h>
#include "descriptor.h"
#include "primitives.h"
#include "pythoncompat.h"


typedef struct {
Expand Down
2 changes: 1 addition & 1 deletion python/descriptor.c
Expand Up @@ -3,7 +3,7 @@
#include <lwpb/lwpb.h>
#include <stdio.h> // for Descriptor_debug_print()
#include "primitives.h"

#include "pythoncompat.h"

/* Descriptor methods */

Expand Down
1 change: 1 addition & 0 deletions python/encoder.c
Expand Up @@ -4,6 +4,7 @@
#include <lwpb/core/encoder2.h>
#include "descriptor.h"
#include "primitives.h"
#include "pythoncompat.h"


/* Encoder methods */
Expand Down
3 changes: 2 additions & 1 deletion python/primitives.c
@@ -1,7 +1,8 @@
#include "primitives.h"
#include "Python.h"
#include "pythoncompat.h"
#include <lwpb/lwpb.h>

#include <stdint.h>

/* Utility functions: scalar type conversion */

Expand Down
14 changes: 14 additions & 0 deletions python/pythoncompat.h
@@ -0,0 +1,14 @@
#ifndef __LWPB_PYTHONCOMPAT_H__
#define __LWPB_PYTHONCOMPAT_H__

/* Py_ssize_t for old Pythons */
/* This code is as recommended by: */
/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
typedef int Py_ssize_t;
# define PY_SSIZE_T_MAX INT_MAX
# define PY_SSIZE_T_MIN INT_MIN
#endif

#endif