[issue4236] Crash when importing builtin module during interpreter shutdown

2010-11-20 Thread Simon Cross

Simon Cross  added the comment:

I'm attaching a patch to relax the check in PyModule_Create2 as suggested by 
the Amaury (http://bugs.python.org/issue4236#msg75409).

The patch uses "PyThreadState_Get()->interp->modules == NULL" to determine 
whether the import machinery has been cleaned up yet.

The test suite still appears to pass.

--
nosy: +hodgestar
Added file: http://bugs.python.org/file19655/check-import-machinery-only.diff

___
Python tracker 
<http://bugs.python.org/issue4236>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2986] difflib.SequenceMatcher not matching long sequences

2010-11-20 Thread Simon Cross

Simon Cross  added the comment:

I made the minor changes needed to get Eli Bendersky's patch to apply against 
3.2. Diff attached.

--
nosy: +hodgestar
Added file: http://bugs.python.org/file19675/issue2986.fix32.5.patch

___
Python tracker 
<http://bugs.python.org/issue2986>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8647] PyUnicode_GetMax is undocumented

2010-11-20 Thread Simon Cross

Simon Cross  added the comment:

This issue is subsumed by #10435 and can probably be closed as a duplicated.

--
nosy: +hodgestar

___
Python tracker 
<http://bugs.python.org/issue8647>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8646] PyUnicode_EncodeDecimal is undocumented

2010-11-20 Thread Simon Cross

Simon Cross  added the comment:

This issue is subsumed by #10435 and can probably be closed as a duplicated.

--
nosy: +hodgestar

___
Python tracker 
<http://bugs.python.org/issue8646>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8645] PyUnicode_AsEncodedObject is undocumented

2010-11-20 Thread Simon Cross

Simon Cross  added the comment:

This issue is subsumed by #10435 and can probably be closed as a duplicated.

--
nosy: +hodgestar

___
Python tracker 
<http://bugs.python.org/issue8645>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10435] Document unicode C-API in reST

2010-11-20 Thread Simon Cross

Changes by Simon Cross :


--
nosy: +hodgestar

___
Python tracker 
<http://bugs.python.org/issue10435>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2986] difflib.SequenceMatcher not matching long sequences

2010-11-24 Thread Simon Cross

Simon Cross  added the comment:

My vote is that this bug be closed and a new feature request be opened. Failing 
that, it would be good to have a concise description of what else we would like 
done (and the priority should be downgraded, I guess).

--

___
Python tracker 
<http://bugs.python.org/issue2986>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2844] int() lies about base parameter

2008-05-13 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

Some quick digging in the code on trunk has revealed that by the time
the base reaches PyInt_FromString in intobject.c, -909 has become 10.
Surrounding numbers seem to come through fine.

--
nosy: +hodgestar

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2844>
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2844] int() lies about base parameter

2008-05-13 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

In int_new in intobject.c the base -909 is used to indicate that no base
has been passed through (presumably because NULL / 0 is a more common
pitfall that -909). Thus -909 is equivalent to base 10.

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2844>
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2517] Error when printing an exception containing a Unicode string

2008-06-09 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

One of the examples Christoph tried was

  unicode(Exception(u'\xe1'))

which fails quite oddly with:

  UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in
position 0: ordinal not in range(128)

The reason for this is Exception lacks an __unicode__ method
implementation so that unicode(e) does something like unicode(str(e))
which attempts to convert the exception arguments to the default
encoding (almost always ASCII) and fails.

Fixing this seems quite important. It's common to want to raise errors
with non-ASCII characters (e.g. when the data which caused the error
contains such characters). Usually the code raising the error has no way
of knowing how the characters should be encoded (exceptions can end up
being written to log files, displayed in web interfaces, that sort of
thing). This means raising exceptions with unicode messages. Using
unicode(e.message) is unattractive since it won't work in 3.0 and also
does not duplicate str(e)'s handling of the other exception __init__
arguments.

I'm attaching a patch which implements __unicode__ for BaseException.
Because of the lack of a tp_unicode slot to mirror tp_str slot, this
breaks the test that calls unicode(Exception). The existing test for
unicode(e) does unicode(Exception(u"Foo")) which is a bit of a non-test.
My patch adds a test of unicode(Exception(u'\xe1')) which fails without
the patch.

A quick look through trunk suggests implementing tp_unicode actually
wouldn't be a huge job. My worry is that this would constitute a change
to the C API for PyObjects and has little chance of acceptance into 2.6
(and in 3.0 all these issues disappear anyway). If there is some chance
of acceptance, I'm willing to write a patch that adds tp_unicode.

--
nosy: +hodgestar
Added file: http://bugs.python.org/file10559/exception-unicode.diff

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2517>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2517] Error when printing an exception containing a Unicode string

2008-06-09 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

Concerning http://bugs.python.org/issue1551432:

I'd much rather have working unicode(e) than working unicode(Exception).
Calling unicode(C) on any class C which overrides __unicode__ is broken
without tp_unicode anyway.

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2517>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2517] Error when printing an exception containing a Unicode string

2008-06-09 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

Benjamin Peterson wrote:
> What version are you using? In Py3k, str is unicode so __str__ can
> return a unicode string.

I'm sorry it wasn't clear. I'm aware that this issue doesn't apply to
Python 3.0. I'm testing on both Python 2.5 and Python 2.6 for the
purposes of the bug.

Code I'm developing that hits these issues are database exceptions with
unicode messages raised inside MySQLdb on Python 2.5.

The patch I submitted is against trunk.

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2517>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2517] Error when printing an exception containing a Unicode string

2008-06-11 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

Attached a patch which implements Nick Coghlan's suggestion. All
existing tests in test_exceptions.py and test_unicode.py pass as does
the new unicode(Exception(u"\xe1")) test.

Added file: 
http://bugs.python.org/file10580/exception-unicode-with-type-fetch.diff

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2517>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2517] Error when printing an exception containing a Unicode string

2008-06-11 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

Re msg67974:
> Minor cleanup of Simon's patch attached - aside from a couple of
> unneeded whitespace changes, it all looks good to me.
>
> Not checking it in yet, since it isn't critical for this week's beta
> release - I'd prefer to leave it until after that has been dealt with.

Thanks for the clean-up, Nick. The mixture of tabs and spaces in the
current object.c was unpleasant :/.

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2517>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2517] Error when printing an exception containing a Unicode string

2008-06-19 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

Justing prodding the issue again now that the betas are out. What's the
next step?

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2517>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3161] Missing import for sys in _abcoll

2008-06-21 Thread Simon Cross

New submission from Simon Cross <[EMAIL PROTECTED]>:

The _hash method of the Set ABC uses sys.maxsize but doesn't import sys.
The attached patch (against trunk) imports sys and adds a test to show
the problem. There are also still some other _abcoll.py cleanups waiting
in issue 2226.

--
components: Library (Lib), Tests
files: abcoll-hash.diff
keywords: patch
messages: 68504
nosy: hodgestar
severity: normal
status: open
title: Missing import for sys in _abcoll
versions: Python 2.6, Python 3.0
Added file: http://bugs.python.org/file10682/abcoll-hash.diff

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3161>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3161] Missing import for sys in _abcoll

2008-06-21 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

One could also make a case for simply removing the _hash method since it
doesn't look like anything is using it? And anything that was using it
would already be broken?

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3161>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3162] ssl.SSLSocket implements methods that are overriden by socket.socket.__init__ and methods with incorrect names.

2008-06-21 Thread Simon Cross

New submission from Simon Cross <[EMAIL PROTECTED]>:

It appears that ssl.SSLSocket attempts to override some of the methods
socket.socket delegates to the underlying _socket.socket methods.
However, this overriding fails because socket.socket.__init__ replaces
all the methods mentioned in _delegate_methods.

These methods are: recv, recvfrom, recv_into, recvfrom_into, send and
sendto.

ssl.SSLSocket implements recv and send. Neither of these overrides will
actually work.  ssl.SSLSocket also implements recv_from and send_to
which seem to be attempts to override recvfrom and sendto.

In the Py3k branch it looks like the overriding done by
socket.socket.__init__ is gone so that these methods are now potentially
overridable. This could potentially be emulated in trunk by checking for
the methods using hasattr(...) before overriding them.

I'm happy to create patches which fix the method names and clean up the
methods on both branches and add tests. I just want to check that I have
an accurate picture of what's needed before starting on them.

--
components: Library (Lib)
messages: 68517
nosy: hodgestar
severity: normal
status: open
title: ssl.SSLSocket implements methods that are overriden by 
socket.socket.__init__ and methods with incorrect names.
versions: Python 2.6, Python 3.0

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3162>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1923] meaningful whitespace can be lost in rfc822_escape

2008-08-28 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

I've just checked that the patch still applies cleanly to 2.6 and it
does and the tests still passes. It looks like the patch has already
been applied to 3.0 but without the test. The test part of the part
applies cleanly to 3.0 too.

--
nosy: +hodgestar

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1923>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1923] meaningful whitespace can be lost in rfc822_escape

2008-09-03 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

Poking the issue.

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1923>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3162] ssl.SSLSocket implements methods that are overriden by socket.socket.__init__ and methods with incorrect names.

2008-09-05 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

I've attached a patch for trunk / 2.6 that adds recv_into and
recvfrom_into methods to ssl.SSLSocket and does a minor re-ordering of
the nasty lambdas in __init__. The recv_into method is a port of the one
from 3.0. The recvfrom_into method is a simple "fail if we have an SSL
object or pass down if we don't".

For the record, I'm against the lambdas in SSLSocket.__init__ and would
prefer the solution I suggested previously of putting a hasattr(...)
check into socket.socket (I can submit a patch if useful).

As is probably abundantly clear at the moment :), none of the SSLSocket
methods in questions have tests in test_ssl -- I will move on to trying
to add them next.

I'm also going to attach a patch for 3.0 which adds recvfrom_into (a
port of the 2.6 one).

--
keywords: +patch
Added file: http://bugs.python.org/file11389/trunk-ssl-methods.patch

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3162>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3162] ssl.SSLSocket implements methods that are overriden by socket.socket.__init__ and methods with incorrect names.

2008-09-05 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

Attach recvfrom_into method patch for 3.0.

Added file: http://bugs.python.org/file11390/3k-ssl-methods.patch

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3162>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3162] ssl.SSLSocket implements methods that are overriden by socket.socket.__init__ and methods with incorrect names.

2008-09-05 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

Tests for recv* and send* methods in 3.0 (2.6 tests coming shortly).

Added file: http://bugs.python.org/file11392/3k-ssl-tests.patch

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3162>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3162] ssl.SSLSocket implements methods that are overriden by socket.socket.__init__ and methods with incorrect names.

2008-09-05 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

Test for recv* and send* in 2.6.

The tests revealed some bugs so this patch fixes those and supercedes
trunk-ssl-methods.patch.

Of particular note is that recv_into called self.read(buf, nbytes) which
isn't supported in _ssl.c in 2.6. I've worked around it by creating a
temporary buffer in the Python code. This isn't great for large
messages, but the alternative is to modify _ssl.c itself (which I
suspect is unlikely to make it in to 2.6 at this stage).

Added file: http://bugs.python.org/file11393/trunk-ssl-tests.patch

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3162>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3162] ssl.SSLSocket implements methods that are overriden by socket.socket.__init__ and methods with incorrect names.

2008-09-05 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

>> self.read(buf, nbytes)

> Shouldn't this function be named readinto()?

There is no readinto function (and I suspect one is unlikely to be added
now). In Py3k SSLSocket.read takes both len and buffer as optional
arguments.

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3162>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3162] ssl.SSLSocket implements methods that are overriden by socket.socket.__init__ and methods with incorrect names.

2008-09-05 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

@Bill Janssen:

There are currently two patch sets which I think should be applied. For
2.6 it's just trunk-ssl-tests.patch. For 3.0 it's 3k-ssl-methods.patch
and 3k-ssl-tests.patch.

@Amaury Forgeot d'Arc

I agree it's not great nomenclature but that's a whole separate can of
worms and not one I want to open in this bug (and in any case, it has
practically zero hope of making it into 2.6/3.0 at this point).

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3162>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3162] ssl.SSLSocket implements methods that are overriden by socket.socket.__init__ and methods with incorrect names.

2008-09-08 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

And thanks for looking at them and applying! :)

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3162>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3823] ssl.wrap_socket() is incompatible with servers that drop privileges, due to keyfile requirement

2008-09-10 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

I've dug around in the code a bit and the keyfile, certfile and ca_certs
filename arguments to SSLSocket.__init__ are passed down into
newPySSLObject in _ssl.c and from there directly to SSL_CTX_* function
from OpenSSL so making these arguments allow file-like objects is going
to be non-trivial.

The options I see are:

* Write the file-like objects out to named temporary files and pass
those through to OpenSSL (seems like a nasty hack and prone to all sorts
of problems).

* Change the which OpenSSL functions are used to setup the certificate
(I definitely don't think this could go into 2.6 or 3.0 at this stage;
also see analysis of current OpenSSL usage below for more difficulties)

* Add an SSL CTX wrapper object and allow that to be passed down to
newPySSLObject instead of the filenames. Then the CTX object could be
created before dropping privileges (I think this is probably also too
big a change to be considered for 2.6 or 3.0 at this point, but it's
what looks best to me at the moment).

The current situation in _ssl.c:

* keyfile is loaded using SSL_CTX_use_PrivateKey_file(...) which loads
the first certificate from keyfile into ctx. We could replace this with
SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey) but we'd have to
load the key ourselves and make sure to follow what OpenSSL does to
maintain compatibility.

* certfile is loaded with SSL_CTX_use_certificate_chain_file(...) which
reads in all the certificates from certfile into ctx. We could read the
certificates in ourselves and them load them one by one using
SSL_CTX_use_certificate(...) and then SSL_CTX_add_extra_chain_cert(...).

* ca_certs is loaded using SSL_CTX_load_verify_locations(...). As fasr
as I can see there is no convenient replacement function for this in
OpenSSL. SSL_CTX_set_client_CA_list(...) will load a list of certificate
names but doesn't load the certificates themselves (so verification
won't be done with them) and SSL_CTX_add_client_CA(...) has the same
issue.  

One could use SSL_CTX_set_cert_store(...) to register callbacks (and
then presumably one can do whatever one wants and can get around the
ca_certs issue) but the man page for SSL_CTX_set_cert_store has the
rather disheartening "Currently no detailed documentation on how to use
the X509_STORE object is available."

All this comes with the proviso that I just started digging into the
OpenSSL manpages today so I'm a long way from being an expert. :)

I can probably find time to create a patch with tests once we have a
clear direction to go in.

@Forest: If you have an details on how non-Python servers go about
loading certificates and then dropping privileges using OpenSSL, that
would be extremely useful.

--
nosy: +hodgestar

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3823>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3932] HTMLParser cannot handle '&' and non-ascii characters in attribute names

2008-09-26 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

I can't reproduce this on current trunk (r66633, 27 Sep 2008). I checked
sys.getdefaultencoding() but that returned 'ascii' as expected and I
even tried language Python with "LANG=C ./python" but that didn't fail
either. Perhaps this has been fixed? It looks like it might originally
have been a problem in the re module from the traceback.

--
nosy: +hodgestar

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3932>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3932] HTMLParser cannot handle '&' and non-ascii characters in attribute names

2008-10-03 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

I've tracked down the cause to the .unescape(...) method in HTMLParser.
The replaceEntities function passed to re.sub() always returns a unicode
character, even when matching string s is a byte string. Changing line
383 to:

  return self.entitydefs[s].encode("utf-8")

makes the test pass. Unfortunately this is obviously not a viable
solution in the general case. The problem is that there is no way to
know what character set to encode in without knowing both the HTTP
headers (which are not available to HTMLParser) and looking at the XML
and HTML headers.

Python 3.0 implicitly rejects non-unicode strings right at the start of
html.parser.HTMLParser.feed(...) by adding '' to the data passed in.

Given Python 3.0's behaviour, the docs should perhaps be updated to say
HTMLParser does not support non-unicode strings? If it should support
byte strings, we'll have to figure out how to handle encoded entity issues.

It's a bit weird that character and entity references outside
tags/attributes result in calls to .entityref(...) and .charref(...)
while those inside get unescape called automatically. Don't really see
what can be done about that though.

--
versions: +Python 2.7

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3932>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2742] example code does not work

2008-05-10 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

This also affects Python 2.4 and 2.6 on Linux systems. Bug
http://bugs.python.org/issue2763 is a duplicate of this one.

The issue is that socketmodule.c doesn't convert empty strings to NULLs
before passing hptr through to the underlying system getaddrinfo(...).
The question is whether to fix the documentation and examples or the
socketmodule.c code.

--
nosy: +hodgestar
versions: +Python 2.4, Python 2.6

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2742>
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2742] example code does not work

2008-05-10 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

Attached a patch to correct the getaddrinfo(...) documentation and the
code example in socket.rst.

--
keywords: +patch
Added file: 
http://bugs.python.org/file10237/getaddrinfo-doesnt-treat-empty-string-as-none.diff

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2742>
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2746] ElementTree ProcessingInstruction uses character entities in content

2008-05-10 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

cElementTree.ElementTree is a copy of ElementTree.ElementTree with the
.parse(...) method replaced, so the original patch for ElementTree
should fix cElementTree too.

The copying of the ElementTree class into cElementTree happens in the
call to boostrap in the init_elementtree() function at the bottom of
_elementtree.c.

--
nosy: +hodgestar

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2746>
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2736] datetime needs and "epoch" method

2008-05-10 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

Attached a patch which adds a .totimetuple(...) method to
datetime.datetime and tests for it.

The intention is that the dt.totimetuple(...) method is equivalent to:
mktime(dt.timetuple()) + (dt.microsecond / 100.0)

--
keywords: +patch
nosy: +hodgestar
Added file: 
http://bugs.python.org/file10251/add-datetime-totimestamp-method.diff

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2736>
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2736] datetime needs and "epoch" method

2008-05-10 Thread Simon Cross

Simon Cross <[EMAIL PROTECTED]> added the comment:

Patch adding documentation for datetime.totimestamp(...).

Added file: 
http://bugs.python.org/file10256/add-datetime-totimestamp-method-docs.diff

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2736>
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1491] BaseHTTPServer incorrectly implements response code 100

2008-05-11 Thread Simon Cross

Changes by Simon Cross <[EMAIL PROTECTED]>:


--
nosy: +hodgestar

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1491>
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4446] Distutils Metadata Documentation Missing "platforms" Keyword

2008-11-27 Thread Simon Cross

New submission from Simon Cross <[EMAIL PROTECTED]>:

The section on Additional meta-data in Doc/distutils/setupscript.rst is
missing any reference to the setup() "platforms" keyword. I've attached
a patch which fills in the basics but there are some outstanding questions:

 - Does note (4) about backwards compatibility with earlier versions of
Python apply?

 - What strings should be used to describe each platform? Perhaps any
final element of an "Operating System ::" trove classifier?

 - Given that we have the classifiers, is the "platforms" keyword
actually needed? Perhaps the docs should just mark it as deprecated? We
would then maybe need to change distutils to populate the platforms key
in PKG-INFO from the classifiers?

--
assignee: georg.brandl
components: Documentation
files: distutils-platforms-keyword-documentation.diff
keywords: patch
messages: 76499
nosy: georg.brandl, hodgestar
severity: normal
status: open
title: Distutils Metadata Documentation Missing "platforms" Keyword
versions: Python 2.5, Python 2.5.3, Python 2.6, Python 2.7, Python 3.0, Python 
3.1
Added file: 
http://bugs.python.org/file12142/distutils-platforms-keyword-documentation.diff

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue4446>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4336] Fix performance issues in xmlrpclib

2008-12-01 Thread Simon Cross

Changes by Simon Cross <[EMAIL PROTECTED]>:


--
nosy: +hodgestar

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue4336>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41903] PyNumber_InPlacePower ignores o3 if o1 implements __ipow__

2020-10-01 Thread Simon Cross


New submission from Simon Cross :

The documentation for PyNumber_InPlacePower [1] reads:

This is the equivalent of the Python statement o1 **= o2 when o3 is Py_None, or 
an in-place variant of pow(o1, o2, o3) otherwise. If o3 is to be ignored, pass 
Py_None in its place (passing NULL for o3 would cause an illegal memory access).

However, if a class A implements __ipow__ then PyNumber_InPlacePower(o1, o2, 
o3) ALWAYS ignores o3 if o1 is an instance of A.

This happens because if A implements __ipow__ then PyNumber_InPlacePower always 
calls the nb_inplace_power slot [2] and the slot always drops the third 
argument [3].

This appears to have always been the case in Python, so likely a small 
documentation patch is all that is required. If people agree, I will open a 
documentation pull request.

[1] 
https://docs.python.org/3/c-api/number.html?highlight=pynumber_inplacepower#c.PyNumber_InPlacePower

[2] https://github.com/python/cpython/blob/master/Objects/abstract.c#L1164

[3] 
https://github.com/python/cpython/blob/master/Objects/typeobject.c#L6631-L6636

--
components: C API
messages: 377758
nosy: hodgestar
priority: normal
severity: normal
status: open
title: PyNumber_InPlacePower ignores o3 if o1 implements __ipow__
type: behavior
versions: Python 3.10, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 
3.9

___
Python tracker 
<https://bugs.python.org/issue41903>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41903] PyNumber_InPlacePower ignores o3 if o1 implements __ipow__

2020-10-01 Thread Simon Cross


Simon Cross  added the comment:

The documentation for __ipow__ [4] suggests that the intention was to support 
the modulus argument, so perhaps that argues for fixing the behaviour of 
PyNumber_InPlacePower.

[4] https://docs.python.org/3/reference/datamodel.html#object.__ipow__

--

___
Python tracker 
<https://bugs.python.org/issue41903>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42262] [C API] Add Py_NewRef() function to get a new strong reference to an object

2020-11-04 Thread Simon Cross


Change by Simon Cross :


--
nosy: +hodgestar

___
Python tracker 
<https://bugs.python.org/issue42262>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16251] pickle special methods are looked up on the instance rather than the type

2014-02-16 Thread Simon Cross

Simon Cross added the comment:

Genshi is affected by the 3.4 regression too (it has a class that defines 
__getnewargs__ and __getattr__).

--
nosy: +hodgestar

___
Python tracker 
<http://bugs.python.org/issue16251>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16251] pickle special methods are looked up on the instance rather than the type

2014-02-16 Thread Simon Cross

Simon Cross added the comment:

I have an ugly work-around for those affected:

def __getattr__(self, name):
# work around for pickle bug in Python 3.4
# see http://bugs.python.org/issue16251
if name == "__getnewargs_ex__":
raise AttributeError("%r has no attribute %r" % (type(self), name))
...

--

___
Python tracker 
<http://bugs.python.org/issue16251>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6280] calendar.timegm() belongs in time module, next to time.gmtime()

2009-08-06 Thread Simon Cross

Changes by Simon Cross :


--
nosy: +hodgestar

___
Python tracker 
<http://bugs.python.org/issue6280>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6280] calendar.timegm() belongs in time module, next to time.gmtime()

2009-10-09 Thread Simon Cross

Simon Cross  added the comment:

The attached patch adds a simple implementation of time.timegm that
calls calendar.timegm. It includes a short test to show that 
time.timegm(time.gmtime(ts)) == ts for various timestamps.

I implemented a pure C version by pulling in the various functions
needed from datetime, but it was a bit messy and a lot more invasive.

Documentation updates are still needed -- I will do those if there is
support for the patch.

--
keywords: +patch
Added file: http://bugs.python.org/file15092/add-timegm-to-time.diff

___
Python tracker 
<http://bugs.python.org/issue6280>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6230] ElementTree.Element and cElementTree.Element have slightly different repr

2009-06-07 Thread Simon Cross

Changes by Simon Cross :


--
nosy: +hodgestar

___
Python tracker 
<http://bugs.python.org/issue6230>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6232] Improve test coverage of ElementTree and cElementTree

2009-06-07 Thread Simon Cross

Changes by Simon Cross :


--
nosy: +hodgestar

___
Python tracker 
<http://bugs.python.org/issue6232>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9514] platform.linux_distribution() under Ubuntu returns ('debian', 'squeeze/sid', '')

2010-08-04 Thread Simon Cross

Simon Cross  added the comment:

I can confirm that I see the ('debian', 'squeeze/sid', '') on py3k and trunk 
but that the Python 2.6 under Ubuntu reports ('Ubuntu', '10.04', 'lucid').

--

___
Python tracker 
<http://bugs.python.org/issue9514>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9514] platform.linux_distribution() under Ubuntu returns ('debian', 'squeeze/sid', '')

2010-08-04 Thread Simon Cross

Simon Cross  added the comment:

I think the problem might be that linux_distribution() reads 
/etc/debian_version first. The contents of the relevant files in /etc look like:

$ cat /etc/debian_version 
squeeze/sid

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION="Ubuntu 10.04.1 LTS"

--

___
Python tracker 
<http://bugs.python.org/issue9514>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9514] platform.linux_distribution() under Ubuntu returns ('debian', 'squeeze/sid', '')

2010-08-04 Thread Simon Cross

Simon Cross  added the comment:

Patch attached to check /etc/lsb-release before checking other files. Taken 
from Ubuntu Python 2.6 copy of platform.py. Applies against trunk (r83728) with 
a small offset against py3k (r83728).

--
keywords: +patch
Added file: http://bugs.python.org/file18389/use-lsb-release-first.diff

___
Python tracker 
<http://bugs.python.org/issue9514>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9514] platform.linux_distribution() under Ubuntu returns ('debian', 'squeeze/sid', '')

2010-08-04 Thread Simon Cross

Simon Cross  added the comment:

I think the intended means of accessing this information is via the lsb_release 
command 
(http://refspecs.freestandards.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/lsbrelease.html).
 That said, I don't know if the file format will change drastically unless 
someone re-implements lsb_release.

--

___
Python tracker 
<http://bugs.python.org/issue9514>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17423] libffi on 32bit is broken on linux

2013-03-15 Thread Simon Cross

Changes by Simon Cross :


--
nosy: +hodgestar

___
Python tracker 
<http://bugs.python.org/issue17423>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26252] Add an example to importlib docs on setting up an importer

2016-02-03 Thread Simon Cross

Changes by Simon Cross :


--
nosy: +hodgestar

___
Python tracker 
<http://bugs.python.org/issue26252>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com