[Python-checkins] r80198 - in python/branches/py3k: Lib/urllib/request.py Misc/NEWS Modules/_scproxy.c setup.py

Ezio Melotti ezio.melotti at gmail.com
Mon Apr 19 08:45:06 CEST 2010


Hi,
the new _scproxy.c file should follow the conventions described in the 
PEP-7 [1]:
* use 4 spaces and no tabs for new files;
* always go on a new line after '}';

[1]: http://www.python.org/dev/peps/pep-0007/

Best Regards,
Ezio Melotti


On 18/04/2010 23.46, ronald.oussoren wrote:
> Author: ronald.oussoren
> Date: Sun Apr 18 22:46:11 2010
> New Revision: 80198
>
> Log:
> For for issue #7154: Port the code that uses
> the SystemConfiguration framework to detect the
> proxy settings on OSX from the trunk to python 3.2
>
>
> Added:
>     python/branches/py3k/Modules/_scproxy.c   (contents, props changed)
> Modified:
>     python/branches/py3k/Lib/urllib/request.py
>     python/branches/py3k/Misc/NEWS
>     python/branches/py3k/setup.py
>
> Modified: python/branches/py3k/Lib/urllib/request.py
> ==============================================================================
> --- python/branches/py3k/Lib/urllib/request.py	(original)
> +++ python/branches/py3k/Lib/urllib/request.py	Sun Apr 18 22:46:11 2010
> @@ -2140,44 +2140,82 @@
>
>
> [...]
>
> Modified: python/branches/py3k/Misc/NEWS
> ==============================================================================
> --- python/branches/py3k/Misc/NEWS	(original)
> +++ python/branches/py3k/Misc/NEWS	Sun Apr 18 22:46:11 2010
> @@ -318,6 +318,9 @@
>   Library
>   -------
>
> +- Issue #7154: urllib.request can now detect the proxy settings on OSX 10.6
> +  (as long as the user didn't specify 'automatic proxy configuration').
> +
>   - Issue #3817: ftplib.FTP.abort() method now considers 225 a valid response
>     code as stated in RFC-959 at chapter 5.4.
>
>
> Added: python/branches/py3k/Modules/_scproxy.c
> ==============================================================================
> --- (empty file)
> +++ python/branches/py3k/Modules/_scproxy.c	Sun Apr 18 22:46:11 2010
> @@ -0,0 +1,261 @@
> +/*
> + * Helper method for urllib to fetch the proxy configuration settings
> + * using the SystemConfiguration framework.
> + */
> +#include<Python.h>
> +#include<SystemConfiguration/SystemConfiguration.h>
> +
> +static int32_t
> +cfnum_to_int32(CFNumberRef num)
> +{
> +	int32_t result;
> +
> +	CFNumberGetValue(num, kCFNumberSInt32Type,&result);
> +	return result;
> +}
> +
> +static PyObject*
> +cfstring_to_pystring(CFStringRef ref)
> +{
> +	const char* s;
> +
> +	s = CFStringGetCStringPtr(ref, kCFStringEncodingUTF8);
> +	if (s) {
> +		return PyUnicode_DecodeUTF8(
> +				s, strlen(s), NULL);
> +
> +	} else {
> +		CFIndex len = CFStringGetLength(ref);
> +		Boolean ok;
> +		PyObject* result;
> +		char* buf;
> +		
> +		buf = PyMem_Malloc(len*4);
> +		if (buf == NULL) {
> +			PyErr_NoMemory();
> +			return NULL;
> +		}
> +
> +		ok = CFStringGetCString(ref,
> +				buf, len * 4,
> +				kCFStringEncodingUTF8);
> +		if (!ok) {
> +			PyMem_Free(buf);
> +			return NULL;
> +		} else {
> +			result = PyUnicode_DecodeUTF8(
> +					buf, strlen(buf), NULL);
> +			PyMem_Free(buf);
> +		}
> +		return result;
> +	}
> +}
> +
> [...]


More information about the Python-checkins mailing list