From 2cfff24f6d59402ef3616c1e5d253e1ab1c77867 Mon Sep 17 00:00:00 2001 From: David Reid Date: Thu, 12 Dec 2013 13:26:31 -0800 Subject: Supress the deprecation warnings by including an __APPLE__ only preamble. --- cryptography/hazmat/bindings/openssl/backend.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cryptography/hazmat/bindings/openssl/backend.py b/cryptography/hazmat/bindings/openssl/backend.py index 1b19ddaa..d093684e 100644 --- a/cryptography/hazmat/bindings/openssl/backend.py +++ b/cryptography/hazmat/bindings/openssl/backend.py @@ -111,8 +111,19 @@ class Backend(object): # is legal, but the following will fail to compile: # int foo(int); # int foo(short); + + preamble = [ +""" +#ifdef __APPLE__ +# include +# undef DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER +# define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER +#endif +""" + ] + lib = ffi.verify( - source="\n".join(includes + functions + customizations), + source="\n".join(preamble + includes + functions + customizations), libraries=["crypto", "ssl"], ) -- cgit v1.2.3 From 76ec34058a30026b62cc6f16a6c172fe5011798d Mon Sep 17 00:00:00 2001 From: David Reid Date: Thu, 12 Dec 2013 13:42:23 -0800 Subject: Attempt to fix nebulous indentation complaints and also re-set after the includes. --- cryptography/hazmat/bindings/openssl/backend.py | 28 ++++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/cryptography/hazmat/bindings/openssl/backend.py b/cryptography/hazmat/bindings/openssl/backend.py index d093684e..044e8cc9 100644 --- a/cryptography/hazmat/bindings/openssl/backend.py +++ b/cryptography/hazmat/bindings/openssl/backend.py @@ -112,18 +112,30 @@ class Backend(object): # int foo(int); # int foo(short); - preamble = [ -""" + pre_includes = [""" #ifdef __APPLE__ -# include -# undef DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER -# define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER +#include +#define __ORIG_DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER \ + DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER +#undef DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER +#define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER #endif -""" - ] +"""] + + post_includes = [""" +#ifdef __APPLE__ +#undef DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER +#define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER \ + __ORIG_DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER +#endif +"""] lib = ffi.verify( - source="\n".join(preamble + includes + functions + customizations), + source="\n".join(pre_includes + + includes + + post_includes + + functions + + customizations), libraries=["crypto", "ssl"], ) -- cgit v1.2.3 From c4f9b1db8b6848b78dd348e9f2ce32752a7b2e39 Mon Sep 17 00:00:00 2001 From: David Reid Date: Thu, 12 Dec 2013 14:11:05 -0800 Subject: formatting more consistent with other cffi secitons. --- cryptography/hazmat/bindings/openssl/backend.py | 40 ++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/cryptography/hazmat/bindings/openssl/backend.py b/cryptography/hazmat/bindings/openssl/backend.py index 044e8cc9..d69fdc45 100644 --- a/cryptography/hazmat/bindings/openssl/backend.py +++ b/cryptography/hazmat/bindings/openssl/backend.py @@ -31,6 +31,24 @@ from cryptography.hazmat.primitives.ciphers.modes import ( CBC, CTR, ECB, OFB, CFB, GCM, ) +_OSX_PRE_INCLUDE = """ +#ifdef __APPLE__ +#include +#define __ORIG_DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER \ + DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER +#undef DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER +#define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER +#endif +""" + +_OSX_POST_INCLUDE = """ +#ifdef __APPLE__ +#undef DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER +#define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER \ + __ORIG_DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER +#endif +""" + @utils.register_interface(CipherBackend) @utils.register_interface(HashBackend) @@ -112,28 +130,10 @@ class Backend(object): # int foo(int); # int foo(short); - pre_includes = [""" -#ifdef __APPLE__ -#include -#define __ORIG_DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER \ - DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER -#undef DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER -#define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER -#endif -"""] - - post_includes = [""" -#ifdef __APPLE__ -#undef DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER -#define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER \ - __ORIG_DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER -#endif -"""] - lib = ffi.verify( - source="\n".join(pre_includes + + source="\n".join([_OSX_PRE_INCLUDE] + includes + - post_includes + + [_OSX_POST_INCLUDE] + functions + customizations), libraries=["crypto", "ssl"], -- cgit v1.2.3 From 2bc3334979ceaee2592e42b3135454ab63b4d009 Mon Sep 17 00:00:00 2001 From: David Reid Date: Thu, 12 Dec 2013 15:19:37 -0800 Subject: alex parens. --- cryptography/hazmat/bindings/openssl/backend.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cryptography/hazmat/bindings/openssl/backend.py b/cryptography/hazmat/bindings/openssl/backend.py index d69fdc45..2e73180f 100644 --- a/cryptography/hazmat/bindings/openssl/backend.py +++ b/cryptography/hazmat/bindings/openssl/backend.py @@ -131,11 +131,13 @@ class Backend(object): # int foo(short); lib = ffi.verify( - source="\n".join([_OSX_PRE_INCLUDE] + - includes + - [_OSX_POST_INCLUDE] + - functions + - customizations), + source="\n".join( + [_OSX_PRE_INCLUDE] + + includes + + [_OSX_POST_INCLUDE] + + functions + + customizations + ), libraries=["crypto", "ssl"], ) -- cgit v1.2.3