[issue25913] base64.a85decode adobe flag incorrectly utilizes <~ as a marker causing error

2015-12-22 Thread Martin Morrison

Martin Morrison added the comment:

The proposed patch does stop requiring the leading <~, but still trims the 
first two characters off the data set. This will no doubt fail in cases where 
there is no leading marker.

I think it will need to explicitly handle the case where the leading marker is 
there vs. not.

--

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



[issue21999] shlex: bug in posix more handling of empty strings

2014-07-17 Thread Martin Morrison

New submission from Martin Morrison:

Minimal testcase of the problem situation is tokenising (with posix mode on):

  ''),

Specifically, an empty string, followed by a non-word character, followed by a 
non-space character. In this case, the token buffer is empty and due to a 
missing check for (self.posix and quoted), an extra token is consumed and 
returned in the wrong order:

 s = shlex.shlex('')abc, posix=True)
 s.get_token()
'abc'
 s.get_token()
')'
 s.get_token()
 

I have patches to fix this issue in both default and 2.7. I've also checked 
there are no other occurrences of the same typo.

--
files: shlex.default.patch
keywords: patch
messages: 223348
nosy: isoschiz
priority: normal
severity: normal
status: open
title: shlex: bug in posix more handling of empty strings
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5
Added file: http://bugs.python.org/file35983/shlex.default.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21999
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21999] shlex: bug in posix more handling of empty strings

2014-07-17 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


Added file: http://bugs.python.org/file35984/shlex.2.7.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21999
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17950] Dynamic classes contain non-breakable reference cycles

2013-05-13 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz, pconnell

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17950
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17927] Argument copied into cell still referenced by frame

2013-05-12 Thread Martin Morrison

Martin Morrison added the comment:

The latest diff (cellfree4.diff) applies correctly to 3.3 (one hunk fails, but 
it's just the one where you've removed a blank line).

The tests also pass successfully with the diff applied.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17927
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17927] Argument copied into cell still referenced by frame

2013-05-10 Thread Martin Morrison

Martin Morrison added the comment:

Our usage of Python would certainly benefit from the backport.

We are embedding Python 3.3 in a system with requirements that lead us to 
disable the gc in most cases, so cycles are an obvious problem for us. Cycles 
created inadvertently, such as this, are the biggest problem. We would probably 
backport the fix anyway, but would prefer not to carry patches and instead pick 
up fixes via 3.3.x releases.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17927
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7475] codecs missing: base64 bz2 hex zlib hex_codec ...

2013-05-02 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7475
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17170] string method lookup is too slow

2013-05-01 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17170
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13533] Would like Py_Initialize to play friendly with host app

2013-04-23 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz, pconnell

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13533
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16427] Faster hash implementation

2013-04-23 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16427
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9141] Allow objects to decide if they can be collected by GC

2013-04-23 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz, pconnell

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9141
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1195571] simple callback system for Py_FatalError

2013-04-23 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz, pconnell

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1195571
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-22 Thread Martin Morrison

Martin Morrison added the comment:

Attached another diff, which includes new test cases to cover all functions 
that weren't covered before - expect print_last. I couldn't see a way of 
getting sys.last_* set to test that function (it seems to require an unhandled 
exception). However, the function is a simple wrapper around print_exception, 
and I have tested it manually in the interactive interpreter.

--
Added file: http://bugs.python.org/file29975/issue17646-5.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17618] base85 encoding

2013-04-21 Thread Martin Morrison

Martin Morrison added the comment:

On 21 Apr 2013, at 17:38, Serhiy Storchaka rep...@bugs.python.org wrote:
 Serhiy Storchaka added the comment:
 
 As for interface, I think 'adobe' flag should be false by default. It makes 
 encoder simpler. ascii85 encoder in Go's standard library doesn't wrap nor 
 add Adobe's brackets. btoa/atob functions looks redundant as we can just use 
 a85encode/a85decoder with appropriate options. Perhaps we should get rid from 
 'adobe' flag in a85decode and autodetect it. And perhaps to do the same with 
 other a85decode's options.

The problem with autodetecting is that it makes it impossible for an 
application to use this library to verify that something is encoded in a 
specific way. Explicit is better than implicit. 

Otherwise, your changes look good to me.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17618
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1635741] Interpreter seems to leak references after finalization

2013-04-20 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz, pconnell

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1635741
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17408] second python execution fails when embedding

2013-04-20 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz, pconnell

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17408
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9634] Add timeout parameter to Queue.join()

2013-04-20 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9634
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14531] Backtrace should not attempt to open stdin file

2013-04-20 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14531
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14621] Hash function is not randomized properly

2013-04-20 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz, pconnell

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14621
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-20 Thread Martin Morrison

Martin Morrison added the comment:

On 20/04/2013 03:54, Benjamin Peterson wrote:
 It would be great to have a test for that. :)

I was afraid you'd say that. ;-)

I'll look at adding test cases to cover the functions not currently
covered (seems most of the print functions aren't, and all of the
'stack' functions aren't).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17800] Expose __del__ when tp_del is populated from C code

2013-04-20 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17800
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-20 Thread Martin Morrison

Martin Morrison added the comment:

On 20 Apr 2013, at 18:55, Serhiy Storchaka rep...@bugs.python.org wrote:
 Serhiy Storchaka added the comment:
 
 Could print_exception() in Lib/idlelib/run.py reuse new traceback functions?

Actually, cleaning up code like that in Idle and the code module and import.c 
was what I was aiming to solve when I stumbled upon the duplication in 
traceback.py - once this patch is in, I plan to raise a separate issue with my 
suggestion for that clean up.

To answer your question directly, the changes I've made here don't solve the 
problem, no. More invasive changes are required, which is why I raised this 
cleanup portion of my change separately (on the assumption this change alone 
wouldn't be controversial, but my wider change might be).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17804] streaming struct unpacking

2013-04-20 Thread Martin Morrison

Martin Morrison added the comment:

I like the idea of this. Two comments:

- I'm no expert on the C API, but in s_iter_unpack do you not need to check for 
failure of PyType_GenericAlloc before calling PyObject_GetBuffer?

- I'm not a fan of separate iter_ functions (and there seemed to be a general 
move away from them elsewhere in Python3; obviously here we have to maintain 
backwards compat though). Perhaps a boolean keyword asiter arg to the regular 
unpack() instead?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17804
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17804] streaming struct unpacking

2013-04-20 Thread Martin Morrison

Martin Morrison added the comment:

On 20 Apr 2013, at 23:01, Martin Morrison rep...@bugs.python.org wrote:
 - I'm not a fan of separate iter_ functions (and there seemed to be a general 
 move away from them elsewhere in Python3; obviously here we have to maintain 
 backwards compat though). Perhaps a boolean keyword asiter arg to the 
 regular unpack() instead?

Thinking about this more, the functionality is probably too radically different 
to overload the same function, so I withdraw the suggestion.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17804
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17468] Generator memory leak

2013-04-19 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +pconnell

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-19 Thread Martin Morrison

Martin Morrison added the comment:

How embarrassing - I guess that'll teach me to try to doctor the diff file. :-)

I've now regenerated the diff, and re-run all the testing, etc. Apologies for 
the churn.

--
Added file: http://bugs.python.org/file29943/issue17646-3.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11549] Build-out an AST optimizer, moving some functionality out of the peephole optimizer

2013-04-19 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16741] `int()`, `float()`, etc think python strings are null-terminated

2013-04-19 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16741
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12535] Chained tracebacks are confusing because the first traceback is minimal

2013-04-19 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12535
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14805] Support display of both __cause__ and __context__

2013-04-19 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14805
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-19 Thread Martin Morrison

Martin Morrison added the comment:

print_tb() wasn't passing the file argument through to print_list() - now 
fixed. I also verified none of the other functions had a similar bug.

--
Added file: http://bugs.python.org/file29944/issue17646-4.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-18 Thread Martin Morrison

Martin Morrison added the comment:

Latest upload has all of the agreed markups from the review.

--
Added file: http://bugs.python.org/file29929/issue17646-2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17618] base85 encoding

2013-04-18 Thread Martin Morrison

Martin Morrison added the comment:

Raised http://bz.selenic.com/show_bug.cgi?id=3894 against Mercurial for them to 
workaround issue14596.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17618
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17618] base85 encoding

2013-04-18 Thread Martin Morrison

Martin Morrison added the comment:

Attached a minor tweak over the last diff - I'd forgotten to fix the Struct 
handling inside the Mercurial implementation as well.

All other comments still apply to this diff.

--
Added file: http://bugs.python.org/file29930/issue17618-5.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17618
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17468] Generator memory leak

2013-04-18 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11182] remove unused undocumented pydoc.Scanner class

2013-04-18 Thread Martin Morrison

Martin Morrison added the comment:

Attached patch does exactly as described. Seems to be unused, and still passes 
all pydoc tests.

--
keywords: +patch
nosy: +isoschiz
Added file: http://bugs.python.org/file29932/issue11182.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11182
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-18 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


Removed file: http://bugs.python.org/file29929/issue17646-2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-18 Thread Martin Morrison

Martin Morrison added the comment:

Sorry, that is an unrelated change I was experimenting with, which I 
accidentally forgot to take out.

Please see the new uploaded diff.

--
Added file: http://bugs.python.org/file29933/issue17646-2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17062] An os.walk inspired replacement for pkgutil.walk_packages

2013-04-18 Thread Martin Morrison

Martin Morrison added the comment:

I threw together a function that implements this. The only variation from the 
proposed signature was adding the onerror argument supported by the other 
similar functions in the module.

--
keywords: +patch
nosy: +isoschiz
Added file: http://bugs.python.org/file29934/issue17062.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17062
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3693] Obscure array.array error message

2013-04-18 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3693
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1647489] zero-length match confuses re.finditer()

2013-04-18 Thread Martin Morrison

Martin Morrison added the comment:

This is still an issue today:

 import re
 [m.groups() for m in re.finditer(r'(^z*)|(\w+)', 'abc')]
[('', None), (None, 'bc')]

--
nosy: +isoschiz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1647489
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17618] base85 encoding

2013-04-17 Thread Martin Morrison

Martin Morrison added the comment:

 Using a trick with struct.unpack() has very unpleasant side effect.
 It might be a few speed up encoding, but creates the Struct object
 with the size is many times larger than the size of the processed
 data. Worse, this object is cached and continues to consume memory.
 Since the size of the data most likely will be unique, almost every
 call of b85encode creates a new object. This will lead to memory
 leaks.

Can you elaborate on this? What leakage is there? I assume this is some 
implementation quirk of the struct module that I'm not aware of.

 Le mercredi 17 avril 2013 à 18:14 +, Serhiy Storchaka a écrit :
 I think we can provide a universal solution compatible (with some
 pre/postprocessing) with both variants. Enclose encoded data in ~
 and ~ or not, and at which column wrap an encoded data. Padding
 can be easy implemented as preprocessing (data + (-len(data)) % 4 *
 b'\0').

 That's ok with me. It's just more work for whoever does it :-)

As I mentioned in one of my previous comments, I was trying very hard 
not to touch the Mercurial solution (b85(en|de)code in the latest 
patch), and just copy it wholesale. Mostly, I don't really like the way 
the solution reads (unpythonic in my eyes), but can understand that for 
this kind of thing that might be the best way.

In my solution (a85(en|de)code) I wrote it from scratch in what I felt 
was a readable way. I can quite easily extend my version to support your 
description of the btoa/atob version (i.e. no bracketing, always pad, 
always wrap output).

I'm less convinced it's sensible to merge the ascii85 implementations 
and the Mercurial b85 one. If you really want that though, I would be in 
favour of using my a85 implementation and just changing the encode inner 
function to use the lookup table.

(we can do all this independently of the function names, which I think 
Antoine and I are agreed should be separate for the different 
implementations)

 As for Git/Mercurial's base85, what other applications use this
 encoding?

 I don't know, but they use it to produce binary diffs (diff chunks
 of binary files), so any application wanting to parse Mercurial/Git
 diffs would have to recognize base85 data.

 (and I also like that the Mercurial/Git variant is the simpler of
 all 3 :-))

I actually prefer the Ascii85 one for the simplicity of the encoding 
(shift base 85 chunks of the input by 33 to get into the printable ascii 
range) rather than the clunky lookup table approach. À chacun son goût. :-)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17618
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17618] base85 encoding

2013-04-17 Thread Martin Morrison

Martin Morrison added the comment:

 Can you elaborate on this? What leakage is there? I assume this is some
 implementation quirk of the struct module that I'm not aware of.

 issue14596.

Thanks for the pointer. I will rework the patch for the encoder/decoders 
to use an explicit Struct so that the inbuilt cache gets bypassed and we 
don't leak,

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17618
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17618] base85 encoding

2013-04-17 Thread Martin Morrison

Martin Morrison added the comment:

New diff. Changes from the last one:

- change in struct handling to avoid issue14596

- Addition of btoa85 and atob85 functions that do legacy 'btoa' 
encoding/decoding. These are just wrappers around a85(en|de)code, which now 
have additional keyword args to control wrapping, padding, framing, and 
whitespace skipping

- New tests covering all 3 variants

--
Added file: http://bugs.python.org/file29911/issue17618-4.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17618
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17618] base85 encoding

2013-04-14 Thread Martin Morrison

Martin Morrison added the comment:

I've updated the Ascii85 algorithms to remove the quadratic complexity, and use 
a single struct.pack/unpack. They should now be much quicker for large input 
strings.

It's difficult to factor out commonality with b85* because the encodings and 
rules differ. This is especially true for decode (where Ascii85 allows 
arbitrary whitespace, so it either has to be stepped through as I've 
implemented it, or it would have to first be sanitised with .replace() or 
similar, which is expensive for large inputs). For encode, the special cases 
supported by Ascii85 make it impossible to *just* use a lookup table, and the 
simplified algorithm for encoding means it isn't necessary to use one at all. I 
also wanted to keep the Mercurial code intact as much as possible, so it can be 
kept in sync in future if necessary.

My notes from the previous diff also still apply if anyone has thoughts on 
those.

--
Added file: http://bugs.python.org/file29852/issue17618-3.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17618
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17618] base85 encoding

2013-04-13 Thread Martin Morrison

Martin Morrison added the comment:

Ok, great. I'll update the patch to include both encoding schemes.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17618
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17618] base85 encoding

2013-04-13 Thread Martin Morrison

Martin Morrison added the comment:

Updated patch that includes both my original implementation of Ascii85, as well 
as the Mercurial implementation of base85. A few notes/questions:

- I named the Mercurial base85 implementation functions with the b85 prefix. 
For the Ascii85 ones, I used a85. I considered overloading the same functions 
with a keyword argument to select which encoding, but rejected that. Thoughts?

- I made only minor modifications to the Mercurial code to use bytes throughout 
(to match all the other APIs in the module). I also updated the docstrings a 
bit. My goal was to change as little as possible to guarantee identical 
behaviour.

- I haven't made the changes to add a pure Python binascii module as suggested 
in msg186216. Although poorly named, base64.py already contains a number of 
other encodings, so this seemed the best place for these too. I'm happy to make 
that change as well though if you really want it as part of this issue.

--
Added file: http://bugs.python.org/file29838/issue17618-2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17618
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17636] Modify IMPORT_FROM to fallback on sys.modules

2013-04-09 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17636
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17618] base85 encoding

2013-04-07 Thread Martin Morrison

Martin Morrison added the comment:

I wrote an implementation from scratch (based on the wikipedia article; I've 
not looked at any existing implementations) in pure Python in the attached 
diff. It includes tests.

Feel free to use it as the pure Python implementation if desired, though I 
won't be offended if you just end up using the Mercurial one. :-)

--
keywords: +patch
nosy: +isoschiz
Added file: http://bugs.python.org/file29717/issue17618.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17618
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17618] base85 encoding

2013-04-07 Thread Martin Morrison

Martin Morrison added the comment:

(sorry for spam)

Forgot to mention, I included an optional keyword argument to support the 
'btoa' shortcut for sequences of space characters as described in the Wikipedia 
article. However, I'm unsure if any other implementation supports this, so 
might not be worth including it in our implementation.

A better feature might be to support full btoa output, but the Wikipedia 
article doesn't have a complete enough specification, and I couldn't find 
(didn't really look for) one elsewhere. If no one uses it though, again. 
probably not worth including it.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17618
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17618] base85 encoding

2013-04-07 Thread Martin Morrison

Martin Morrison added the comment:

Ok, having now looked at mercurial's implementation... it looks like they 
implemented the RFC1924 version, whereas my implementation is the Ascii85 
version (and I verified it against, amongst others: 
http://www.tools4noobs.com/online_tools/ascii85_encode/ ).

The Ascii85 version is what is used with PDF, and the default output format for 
the equivalent Ruby library, so seems useful to have. So I guess what might be 
desirable is to have both in the codebase?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17618
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17618] base85 encoding

2013-04-07 Thread Martin Morrison

Martin Morrison added the comment:

Ok, I'm not even sure that Mercurial follows RFC1924! That RFC is specifically 
for encoding IPv6 addresses, and mandates that the calculations be performed on 
a 128bit integer.

The Mercurial implementation seems to follow the Ascii85 policy of taking each 
4 bytes separately and doing 32bit arithmetic, but uses the lookup table from 
RFC1924, and is less lenient about spacing, and has no compression for 
sequences of zeroes.

It therefore looks like Mercurial (and I guess Git) have their own, 
non-standard base64 encoding. The Web at large mostly has standard Ascii85 
encoding/decoding described. RFC1924 itself has a Python implementation on 
Github:

https://github.com/drkjam/netaddr/blob/rel-0.7.x/netaddr/ip/rfc1924.py

So I'm not sure what you want to do. I would suggest a standard Ascii85 encoder 
is definitely useful, and provides feature parity with Ruby. If we want the 
standard library to be able to read/write Mercurial/Git base64 encoded files, 
then I guess that can be added too. If we think RFC1924 is useful/used, then 
the implementation in the netaddr lib looks right.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17618
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-06 Thread Martin Morrison

New submission from Martin Morrison:

traceback.py contains a lot of code duplication, which makes it fragile in the 
face of changes (i.e. special cases) to the stack/traceback output (I am 
separately working on just such a change).

The attached patch refactors the code to reduce to a single function for each 
bit of logic, wrapped by the various existing APIs. The new helper functions 
are refactored as generators so as not to create unnecessary transient lists 
(not that stacks usually get very big anyway).

I've fully tested the replacement module, and it passes all the traceback tests 
in the standard suite.

--
components: Library (Lib)
files: traceback.diff
keywords: patch
messages: 186142
nosy: isoschiz
priority: normal
severity: normal
status: open
title: traceback.py has a lot of code duplication
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file29692/traceback.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-06 Thread Martin Morrison

Martin Morrison added the comment:

I hadn't spotted that one!

My refactor goes further (consolidates all duplicates, not just the tb ones), 
is implemented the way you suggested therein (print in terms of extract), and 
is more efficient in that it uses generators for all intermediate iterators. 

However, I'm happy to either attach my diff to that issue, refactor mine in 
terms of that one, or whatever you think is best.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14905] zipimport.c needs to support namespace packages when no 'directory' entry exists

2013-04-03 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


--
nosy: +isoschiz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14905
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-05-14 Thread Martin Morrison

Martin Morrison martin.morri...@gmail.com added the comment:

This solution has some very undesirable properties - namely that Mar 1st is now 
less than Feb 29th!

It seems like the correct follow up fix would be to adjust the date of the 
returned struct_time back to 1900. The struct_time object doesn't have the 
validation issue, so this works fine. This pair of fixes then nicely 
circumvents the intermediate datetime object's checking, while providing a 
consistent end result.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-02-29 Thread Martin Morrison

New submission from Martin Morrison martin.morri...@gmail.com:

time.strptime without a year fails on Feb 29 with:

 time.strptime(Feb 29, %b %d)
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib/python2.6/_strptime.py, line 454, in _strptime_time
return _strptime(data_string, format)[0]
  File /usr/lib/python2.6/_strptime.py, line 440, in _strptime
datetime_date(year, 1, 1).toordinal() + 1
ValueError: day is out of range for month

This is due to the use of 1900 as the default year when parsing. It would be 
nice to have an optional defaults keyword argument to the strptime function 
that can be used to override the defaults, thus allowing leap year dates to be 
parsed without specifying the date.

(Note: the code in question attempted to set the year *after* the parse so that 
ultimately there is a valid struct_time, but since the parse never succeeds, 
this can't work).

--
components: Library (Lib)
messages: 154621
nosy: Martin.Morrison
priority: normal
severity: normal
status: open
title: time.strptime without a year fails on Feb 29
type: behavior
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com