Re: [Python-3000] Pleaswe help with the countdown to zero failing tests in the struni branch!

2007-08-08 Thread Martin v. Löwis
>> It's in Modules/timemodule.c, line 691: >> PyModule_AddObject(m, "tzname", >>Py_BuildValue("(zz)", tzname[0], tzname[1])); >> >> According to MSDN, tzname is a global variable; the contents is somehow >> derived from the TZ environment variable (which is not s

Re: [Python-3000] Immutable bytes type and dbm modules

2007-08-08 Thread Jeffrey Yasskin
I agree completely with Talin's suggestion for the arrangement of the mutable and immutable alternatives, but there are a couple points here that I wanted to answer. On 8/6/07, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > For low-level I/O code, I totally agree that a mutable buffery object >

Re: [Python-3000] Immutable bytes type and dbm modules

2007-08-08 Thread Greg Ewing
Adam Olsen wrote: > Less confusing to prohibit concatenation of mismatched types. There's > always trivial workarounds (ie () + tuple([]) or .extend()). Normally I would agree, but in this case I feel that it would be inconvenient. With the scheme I proposed, code that treats bytes as read-only d

Re: [Python-3000] Immutable bytes type and dbm modules

2007-08-08 Thread Greg Ewing
Georg Brandl wrote: > mutable = mutable + immutable > > mutable += immutable I wouldn't have a problem with these being different. They're already different with list + tuple (although in that case, one of them is disallowed). -- Greg ___ Python-3000

Re: [Python-3000] Immutable bytes type and dbm modules

2007-08-08 Thread Greg Ewing
Georg Brandl wrote: > NB: when dealing with sets and frozensets, you get the type of > the first operand. Doing something different here is confusing. Hmmm, I don't think I would have designed it that way. I might be willing to go along with that precedent, though. -- Greg _

[Python-3000] py3k-struni: proposition to fix ctypes bug, ctypes c_char creates bytes

2007-08-08 Thread Victor Stinner
Hi, I hear Guido's request to fix last py3k-struni bugs. I downloaded subversion trunk and started to work on ctypes tests. The problem is that ctypes c_char (and c_char_p) creates unicode string instead of byte string. I attached a proposition (patch) to change this behaviour (use bytes for c

Re: [Python-3000] py3k-struni: proposition to fix ctypes bug, ctypes c_char creates bytes

2007-08-08 Thread Guido van Rossum
Thanks! Would you mind submitting to SF and assigning to Thomas Heller (theller I think)? And update the wiki (http://wiki.python.org/moin/Py3kStrUniTests) On 8/8/07, Victor Stinner <[EMAIL PROTECTED]> wrote: > Hi, > > I hear Guido's request to fix last py3k-struni bugs. I downloaded subversion >

Re: [Python-3000] py3k-struni: proposition to fix ctypes bug, ctypes c_char creates bytes

2007-08-08 Thread Thomas Heller
Victor Stinner schrieb: > Hi, > > I hear Guido's request to fix last py3k-struni bugs. I downloaded subversion > trunk and started to work on ctypes tests. > > The problem is that ctypes c_char (and c_char_p) creates unicode string > instead of byte string. I attached a proposition (patch) to c

Re: [Python-3000] py3k-struni: proposition to fix ctypes bug, ctypes c_char creates bytes

2007-08-08 Thread Guido van Rossum
On 8/8/07, Thomas Heller <[EMAIL PROTECTED]> wrote: > OTOH, I'm a little bit confused about the bytes type. I think this behaviour > is a little bit confusing, but maybe that's just me: > > >>> b"abc"[:] > b'abc' > >>> b"abc"[:1] > b'a' > >>> b"abc"[1] > 98 > >>> b"abc"[1] = 42 > >>> b"abc"[1] = "

Re: [Python-3000] [Python-Dev] Regular expressions, Unicode etc.

2007-08-08 Thread Martin v. Löwis
> My second one is about Unicode. I really, but REALLY regard it as > a serious defect that there is no escape for printing characters. > Any code that checks arbitrary text is likely to need them - yes, > I know why Perl and hence PCRE doesn't have that, but let's skip > that. That is easy to ad

Re: [Python-3000] [Python-Dev] Regular expressions, Unicode etc.

2007-08-08 Thread Mike Klaas
On 8-Aug-07, at 2:28 AM, Nick Maclaren wrote: > I have needed to push my stack to teach REs (don't ask), and am > taking a look at the RE code. I may be able to extend it to support > RFE 694374 and (more importantly) atomic groups and possessive > quantifiers. While I regard such things as revo

[Python-3000] Removal of cStringIO and StringIO module

2007-08-08 Thread Christian Heimes
I've spent some free time today to work on a patch that removes cStringIO and StringIO from the py3k-struni branch. The patch is available at http://www.python.org/sf/1770008 It adds a deprecation warning to StringIO.py and a facade cStringIO.py. Both modules act as an alias for io.StringIO. You m

Re: [Python-3000] py3k-struni: proposition to fix ctypes bug, ctypes c_char creates bytes

2007-08-08 Thread Victor Stinner
On Wednesday 08 August 2007 18:45:38 you wrote: > Thanks! Would you mind submitting to SF and assigning to Thomas Heller > (theller I think)? > > And update the wiki (http://wiki.python.org/moin/Py3kStrUniTests) Thomas Heller did it. Thanks ;-) Victor Stinner aka haypo http://hachoir.org/ ___

Re: [Python-3000] Removal of cStringIO and StringIO module

2007-08-08 Thread Brett Cannon
On 8/8/07, Christian Heimes <[EMAIL PROTECTED]> wrote: > I've spent some free time today to work on a patch that removes > cStringIO and StringIO from the py3k-struni branch. The patch is > available at http://www.python.org/sf/1770008 > Thanks for the work! And with Alexandre's Summer of Code pr

Re: [Python-3000] Immutable bytes type and dbm modules

2007-08-08 Thread Jim Jewett
On 8/8/07, Georg Brandl <[EMAIL PROTECTED]> wrote: > Jim Jewett schrieb: > > I'm not sure why you would need a literal for the mutable version. > > How often do you create a new buffer with initial values? (Note: not > > pointing to existing memory; creating a new one.) > The same reason that y

[Python-3000] Moving to a "py3k" branch soon

2007-08-08 Thread Guido van Rossum
I would like to move to a new branch soon for all Py3k development. I plan to name the branch "py3k". It will be branched from py3k-struni. I will do one last set of merges from the trunk via p3yk (note typo!) and py3k-struni, and then I will *delete* the old py3k and py3k-struni branches (you w

Re: [Python-3000] C API cleanup str

2007-08-08 Thread Neal Norwitz
On 8/5/07, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > >> I agree. We should specify that somewhere, so we have a recorded > >> guideline to use in case of doubt. > > > > But where? Time to start a PEP for the C API perhaps? > > I would put it into the API documentation. We can put a daily-gener

[Python-3000] tp_bytes and __bytes__ magic method

2007-08-08 Thread Christian Heimes
Hey Pythonistas! Victor Stinner just made a good point at #python. The py3k has no magic method and type slot for bytes. Python has magic methods like __int__ for int(ob) and __str__ for str(ob). Are you considering to add a __bytes__ method and tp_bytes? I can think of a bunch of use cases for a

Re: [Python-3000] tp_bytes and __bytes__ magic method

2007-08-08 Thread Victor Stinner
On Thursday 09 August 2007 00:22:51 Christian Heimes wrote: > Hey Pythonistas! > > Victor Stinner just made a good point at #python. The py3k has no magic > method and type slot for bytes. And another problem: mix of __str__ and __unicode__ methods. class A: def __str__(self): return '__str__'

Re: [Python-3000] tp_bytes and __bytes__ magic method

2007-08-08 Thread Guido van Rossum
On 8/8/07, Christian Heimes <[EMAIL PROTECTED]> wrote: > Victor Stinner just made a good point at #python. The py3k has no magic > method and type slot for bytes. Python has magic methods like __int__ > for int(ob) and __str__ for str(ob). Are you considering to add a > __bytes__ method and tp_byte

Re: [Python-3000] tp_bytes and __bytes__ magic method

2007-08-08 Thread Guido van Rossum
The plan is to kill __unicode__ and only use __str__. But we're not quite there yet. On 8/8/07, Victor Stinner <[EMAIL PROTECTED]> wrote: > On Thursday 09 August 2007 00:22:51 Christian Heimes wrote: > > Hey Pythonistas! > > > > Victor Stinner just made a good point at #python. The py3k has no mag

Re: [Python-3000] tp_bytes and __bytes__ magic method

2007-08-08 Thread Victor Stinner
On Thursday 09 August 2007 00:54:47 Guido van Rossum wrote: > On 8/8/07, Christian Heimes <[EMAIL PROTECTED]> wrote: > > Victor Stinner just made a good point at #python. The py3k has no magic > > method and type slot for bytes (...) > > I can think of a bunch of use cases for a magic method. > > S

Re: [Python-3000] tp_bytes and __bytes__ magic method

2007-08-08 Thread Christian Heimes
Guido van Rossum wrote: >> I can think of a bunch of use cases for a magic method. > > Such as? The __bytes__ method could be used to implement a byte representation of an arbitrary object. The byte representation can then be used to submit the object over wire or dump it into a file. In Python 2

[Python-3000] fix email module for bytes/str

2007-08-08 Thread Victor Stinner
Hi, I started to work on email module, but I have trouble to understand if a function should returns bytes or str (because I don't know email module). Header.encode() -> bytes? Message.as_string() -> bytes? decode_header() -> list of (bytes, str|None) or (str, str|None)? base64MIME.encode() -> b

Re: [Python-3000] tp_bytes and __bytes__ magic method

2007-08-08 Thread Guido van Rossum
> On Thursday 09 August 2007 00:54:47 Guido van Rossum wrote: > > On 8/8/07, Christian Heimes <[EMAIL PROTECTED]> wrote: > > > Victor Stinner just made a good point at #python. The py3k has no magic > > > method and type slot for bytes (...) > > > I can think of a bunch of use cases for a magic met

Re: [Python-3000] fix email module for bytes/str

2007-08-08 Thread Guido van Rossum
You might want to send this to the email-sig. On 8/8/07, Victor Stinner <[EMAIL PROTECTED]> wrote: > Hi, > > I started to work on email module, but I have trouble to understand if a > function should returns bytes or str (because I don't know email module). > > Header.encode() -> bytes? > Message.

[Python-3000] bytes regular expression?

2007-08-08 Thread Victor Stinner
Hi, Since Python 3000 regular expressions are now Unicode by default, how can I use bytes regex? Very simplified example of my problem: import re print( re.sub("(.)", b"[\\1]", b'abc') ) This code fails with exception: File "(...)/py3k-struni/Lib/re.py", line 241, in _compile_repl p =

Re: [Python-3000] C API cleanup str

2007-08-08 Thread skip
Neal> That's already been done for a while: Neal> http://docs.python.org/dev/3.0/ Cool. If the Google Sprint Chicago Edition becomes a reality (we've been discussing it on [EMAIL PROTECTED]) and I get to go I think I will probably devote much of my time to documentation. Skip __

Re: [Python-3000] bytes regular expression?

2007-08-08 Thread Guido van Rossum
A quick temporary hack is to use buffer(b'abc') instead. (buffer() is so incredibly broken that it lets you hash() even if the underlying object is broken. :-) The correct solution is to fix the re library to avoid using hash() directly on the underlying data type altogether; that never had sound

Re: [Python-3000] C API cleanup str

2007-08-08 Thread Georg Brandl
[EMAIL PROTECTED] schrieb: > Neal> That's already been done for a while: > Neal> http://docs.python.org/dev/3.0/ > > Cool. If the Google Sprint Chicago Edition becomes a reality (we've been > discussing it on [EMAIL PROTECTED]) and I get to go I think I will probably > devote much of my t

Re: [Python-3000] C API cleanup str

2007-08-08 Thread Brett Cannon
On 8/8/07, Georg Brandl <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] schrieb: > > Neal> That's already been done for a while: > > Neal> http://docs.python.org/dev/3.0/ > > > > Cool. If the Google Sprint Chicago Edition becomes a reality (we've been > > discussing it on [EMAIL PROTECTED])