summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2015-01-13 07:52:48 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2015-01-13 07:55:31 +0000
commit944fbfb426276358c92410c5f40db28262674fcc (patch)
tree02b19ad3874bb2f0f163913028558c3aeebc519b
parent9d87b9f099cf1dd3978375d3a4a109221570e7f9 (diff)
downloadswig-944fbfb426276358c92410c5f40db28262674fcc.tar.gz
Python 3 default args fix
Fix 0U and 0L as default args for Python 3 (tests committed in previously commit of default_args.i). Relates to issue #294.
-rw-r--r--Examples/test-suite/default_args.i6
-rw-r--r--Source/Modules/python.cxx8
2 files changed, 11 insertions, 3 deletions
diff --git a/Examples/test-suite/default_args.i b/Examples/test-suite/default_args.i
index 53f88fe37..bcb8766a8 100644
--- a/Examples/test-suite/default_args.i
+++ b/Examples/test-suite/default_args.i
@@ -27,6 +27,12 @@
void seek3(long offset = 0L) {}
void seek4(unsigned long offset = 0UL) {}
void seek5(unsigned long offset = 0U) {}
+ void seek6(unsigned long offset = 02U) {}
+ void seek7(unsigned long offset = 00U) {}
+ void seek8(unsigned long offset = 1U) {}
+ void seek9(long offset = 1L) {}
+ void seekA(long long offset = 1LL) {}
+ void seekB(unsigned long long offset = 1ULL) {}
// Anonymous arguments
int anonymous(int = 7771);
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index abfe29823..dde1b6023 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -1923,9 +1923,11 @@ public:
// to be "0o" in Python 3 only (and as long as we still support Python
// 2.5, this can't be done unconditionally).
if (py3) {
- String *res = NewString("0o");
- Append(res, NewStringWithSize(s + 1, end - s - 1));
- return res;
+ if (end - s > 1) {
+ String *res = NewString("0o");
+ Append(res, NewStringWithSize(s + 1, end - s - 1));
+ return res;
+ }
}
}
}