[issue10231] SimpleHTTPRequestHandler directory bugs

2017-11-25 Thread Hallvard B Furuseth
Hallvard B Furuseth <h.b.furus...@usit.uio.no> added the comment: On 26/11/17 04:59, Martin Panter wrote: > That leaves the fourth complaint, which I don’t understand: ‘translate_path() > does not handle initial "."/".." on non-Posix systems’. > > As far

[issue10133] multiprocessing: conn_recv_string() broken error handling

2012-06-12 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Richard Oudkerk rep...@bugs.python.org wrote: Thanks for the patch, I have applied it. (I don't think there was a problem with the promotion rules because res was a never converted to UINT32.) True now that res is a Py_ssize_t

[issue10231] SimpleHTTPRequestHandler directory bugs

2010-11-22 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Senthil Kumaran writes: I have doubts on the validity of this bug itself. - First is, query and fragment are usually for the file being served from the webserver, not on the directories. If there are characters

[issue10070] 2to3 wishes for already-2to3'ed files

2010-11-19 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Éric Araujo writes: That's fair enough. :) Do you want to close this feature request then? Me? No. I just figured that after all this arguing, I should mention that closing it as out of scope is not something I'll

[issue10458] 2.7 += re.ASCII

2010-11-19 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: Could Python 2.7 get a dummy re.ASCII = re.A flag, for source code compatibility with 3.2? -- components: Regular Expressions messages: 121520 nosy: hfuru priority: normal severity: normal status: open title: 2.7

[issue10350] errno is read too late

2010-11-15 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Terry J. Reedy writes: There is one relocation of memory freeing Modules/timemodule.c does '#if,if(..errno..)' after PyMem_Free(outbuf), which can overwrite the desired errno. Instead of reading errno into a temporary, I moved

[issue10070] 2to3 wishes for already-2to3'ed files

2010-11-15 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Martin v. Löwis writes: As this code is in a Python 2.x block: why does this change cause problems to you? You are supposed to run the 2to3 result in Python 3, and this conversion result will run correctly in Python 3. As I've

[issue10070] 2to3 wishes for already-2to3'ed files

2010-11-15 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Hallvard B Furuseth writes: Martin v. Löwis writes: Ok, I can propose two different spellings of this without any macro processor: (...) Both your examples fit my request perfectly. Pieces of code which I presume are correct

[issue10070] 2to3 wishes for already-2to3'ed files

2010-11-15 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Éric Araujo writes: I think 2to3 is designed to take 2.x code and turn it into 3.x code. Codebases using tricks and hacks to support both 2.x and 3.x (like the example you linked to) cannot be handled by 2to3. That's fair enough

[issue10359] ISO C cleanup

2010-11-12 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: STINNER Victor writes: Python-ast.c: why do you move req_name and req_type outside PyAST_obj2mod()? Eh, in case I've managed to be sufficiently unclear: The reason I modified it at all was because the initialization is not valid

[issue10070] 2to3 wishes for already-2to3'ed files

2010-11-12 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Martin v. Löwis writes: And I still don't understand the rationale for this request. Can you please post an example Python module that has this markup you are asking for, so I can show you how to achieve what you want without

[issue10308] Modules/getpath.c bugs

2010-11-11 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: STINNER Victor writes: The following change is useless, it cannot overflow: -if (n + k MAXPATHLEN) +if (k MAXPATHLEN - n) k = MAXPATHLEN - n; n and k maximum values are MAXPATHLEN (and the maximum value

[issue10325] PY_LLONG_MAX co - preprocessor constants or not?

2010-11-09 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: No, PY_LLONG_MAX lacks a paren. Found by the revolutionary method of actually testing it (made the previous branches #if 0's). bugs.python.org is not responding, but here's what I'm using now: Index: Include/pyport.h

[issue10312] intcatcher() can deadlock

2010-11-09 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Sorry, my patch is useless if the OS calls the handler with the signal blocked. It should also unblock the signal before doing anything which can do FILE* operations. And set the handler again? Or just leave the next signal

[issue10359] ISO C cleanup

2010-11-09 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: ,AIric Araujo writes: By the way, do these changes actually fix errors or are they just cleanups and pedantic (not a slight) fixes? I've used compilers where they'd be compile errors, though I found them just with gcc -pedantic

[issue10359] ISO C cleanup

2010-11-09 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: STINNER Victor writes: Python-ast.c: why do you move req_name and req_type outside PyAST_obj2mod()? Because there's no need to initialize the arrays each time PyAST_obj2mod is called. C90-friendly code inside PyAST_obj2mod would

[issue10359] ISO C cleanup

2010-11-09 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Hallvard B Furuseth writes: (...) which is what the current code actually executes. Er, I mean, that's what it does with req_type. The 'static' for req_name is an optimization of the current code

[issue9873] urllib.parse: Allow bytes in some APIs that use string literals internally

2010-11-09 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: urlunparse(url or params = bytes object) produces a result with the repr of the bytes object if params is set. urllib.parse.urlunparse(['http', 'host', '/dir', b'params', '', '']) -- http://host/dir;b'params' That's confusing

[issue10070] 2to3 wishes for already-2to3'ed files

2010-11-09 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Hi, I'm back... I've been reading your last message a few times and I'm not sure what I'm to reconsider. We've had a way of talking past each toerh before, as far as I can remember. I think my request still now translates

[issue10375] 2to3 print(single argument)

2010-11-09 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: Could 2to3 without -p notice more cases of print(single argument), to avoid slapping another () around them? For example: print(2*3) print(, .join(dir)) print(very + long + single + argument) My internal bug

[issue960325] --require feature option for configure/make (fail if building not possible)

2010-11-09 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Just for the record, I think you read this a bit too fast before closing: Terry J. Reedy writes: I am closing this as some combination of wrong, inapplicable, out-of-date, and postponed. 1. (...) For bz2, there is This module

[issue10325] PY_LLONG_MAX co - preprocessor constants or not?

2010-11-08 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Mark Dickinson writes: Here's a patch (against py3k) incorporating your suggestions. Would you be willing to review? Looks fine to me. (Actually the gcc branch makes the same assumptions as the final branch, but then I expect

[issue10350] errno is read too late

2010-11-08 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: errno is sometimes read too late after the error: After another call may have modified it. Here's a patch against py3k. Most of it or a variant applies to 2.7 too, but I haven't really looked at that. I've not looked at math

[issue10325] PY_LLONG_MAX co - preprocessor constants or not?

2010-11-08 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: I wrote: BTW, do you know of any modern non-Windows platforms that don't define LLONG_MIN and LLONG_MAX? It may well be that the two's complement fallback hasn't been exercised in recent years. Anyting compiled with strict

[issue10359] ISO C cleanup

2010-11-08 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: Here are some ISO C conformance patches, and a minor cleanup I encountered along the way. Lib/distutils/tests/test_config_cmd.py // comment -- /* comment */. Lib/distutils/tests/test_build_ext.py, Objects/weakrefobject.c, Modules

[issue10325] PY_LLONG_MAX co - preprocessor constants or not?

2010-11-08 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Hallvard B Furuseth writes: Looks fine to me. Hold on.. #elif defined SIZEOF_LONG_LONG would be a bit safer than #else. -- ___ Python tracker rep...@bugs.python.org http

[issue10325] PY_LLONG_MAX co - preprocessor constants or not?

2010-11-06 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Mark Dickinson writes: Thanks for the report; I agree that there's a potential issue here, and I also think that all these definitions *should* be preprocessor defines. Indeed, my suggestion to castify everything for uniformity

[issue10343] urllib.parse problems with bytes vs str

2010-11-06 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: urlunparse(url or params = bytes object) produces a result with the repr of the bytes object. urllib.parse.urlunparse(['http', 'host', '/dir', b'params', '', '']) -- http://host/dir;b'params' That's confusing since urllib

[issue10325] PY_LLONG_MAX co - preprocessor constants or not?

2010-11-06 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: I wrote: #define PY_LLONG_MAX \ (1 + 2 * ((Py_LL(1) (CHAR_BIT*SIZEOF_LONG_LONG-2)) - 1)) #define PY_ULLONG_MAX (PY_LLONG_MAX * 2ULL + 1) Eh, Py_ULL(2). (...) I just get peeved when people get this wrong, then document

[issue10320] printf %qd is nonstandard

2010-11-05 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: Modules/_ctypes/callproc.c:PyCArg_repr() uses sprintf(%qd, long long), which is a GNU (and more?) extension. ISO C99 says %lld. Instead, use % PY_FORMAT_LONG_LONG d from pyconfig.h/pyport.h. Kills off #ifdef MS_WIN32 too

[issue10313] Reassure user: test_os BytesWarning is OK

2010-11-05 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Antoine Pitrou writes: Hallvard, if you update your py3k working copy, do these warnings disappear? Yes, switching to the svn version shuts them up. -- ___ Python tracker rep

[issue10311] Signal handlers must preserve errno

2010-11-05 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Antoine Pitrou writes: By the way, I'd like to clear out a potential misunderstanding: the function you are patching doesn't call Python signal handlers in itself (those registered using signal.signal()). (...) Good point - I'm

[issue10311] Signal handlers must preserve errno

2010-11-05 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Antoine Pitrou writes: I think it is extremely unlikely that mutating errno in a signal handler is unsafe (after all, the library functions called from that handler can mutate errno too: that's the whole point of the patch IIUC

[issue10325] PY_LLONG_MAX co - preprocessor constants or not?

2010-11-05 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: Include/pyport.h invites potential compile errors with the definitions #define PY_LLONG_MIN LLONG_MIN #define PY_LLONG_MAX LLONG_MAX #define PY_ULLONG_MAX ULLONG_MAX which can fall back to gcc variants or to #else

[issue10308] Modules/getpath.c bugs

2010-11-04 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: Patches for getpath.c in Python 2.7 and 3.2a3: 2.7 chunk#2: copy_absolute() would use uninitialized data if getcwd() failed. The fix is equivalent to what 3.2a3 does. 3.2a3 chunk#2: search_for_exec_prefix() did 'unsigned value

[issue10309] dlmalloc.c needs _GNU_SOURCE for mremap()

2010-11-04 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: dlmalloc uses mremap() which is undeclared on Linux, needs _GNU_SOURCE. This can break at least on hosts where void* = 64 bits and int (default return type) 32 bits, since some bits in the return type are lost. A minimal patch

[issue10310] signed:1 bitfields rarely make sense

2010-11-04 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: In Python 2.7 and 3.2a3, Modules/_io/textio.c uses signed:1 bitfields. They have value -1 or 0 in two's complement, but are not used thus here: gcc complains of bitfield = 1 overflow. If the point was that they are assigned

[issue10311] Signal handlers must preserve errno

2010-11-04 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: Signal handlers that can change errno, must restore it. I enclose a patch for 2.7, 3.2a3/Modules/signalmodule.c which also rearranges the code to make this a bit easier. The patch does if (errno != save_errno) errno

[issue10312] intcatcher() can deadlock

2010-11-04 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: Parser/intrcheck.c:intcatcher() can do FILE* operations, which can deadlock if the interrupt happens while a FILE* operation on the same FILE holds a mutex for the FILE. I've seen this happen elsewhere. It'd rather be a pity

[issue10311] Signal handlers must preserve errno

2010-11-04 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Parser/intrcheck.c:intcatcher() should do the same. Covered in Issue 10312. Antoine Pitrou writes: This is a good idea IMO. It would be better if you minimized style changes, so that the patch is easier to review. I'm afraid

[issue10231] SimpleHTTPRequestHandler directory bugs

2010-11-04 Thread Hallvard B Furuseth
Changes by Hallvard B Furuseth h.b.furus...@usit.uio.no: -- versions: +Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10231

[issue10133] multiprocessing: conn_recv_string() broken error handling

2010-11-04 Thread Hallvard B Furuseth
Changes by Hallvard B Furuseth h.b.furus...@usit.uio.no: -- versions: +Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10133

[issue10308] Modules/getpath.c bugs

2010-11-04 Thread Hallvard B Furuseth
Changes by Hallvard B Furuseth h.b.furus...@usit.uio.no: -- versions: +Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10308

[issue10309] dlmalloc.c needs _GNU_SOURCE for mremap()

2010-11-04 Thread Hallvard B Furuseth
Changes by Hallvard B Furuseth h.b.furus...@usit.uio.no: -- versions: +Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10309

[issue10312] intcatcher() can deadlock

2010-11-04 Thread Hallvard B Furuseth
Changes by Hallvard B Furuseth h.b.furus...@usit.uio.no: -- versions: +Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10312

[issue10311] Signal handlers must preserve errno

2010-11-04 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Amaury Forgeot d'Arc writes: This issue is not really relevant on Windows: - signals are actually run in a new thread specially created. - errno is a thread-local variable; its value is thus local to the signal handler, same

[issue10313] Reassure user: test_os BytesWarning is OK

2010-11-04 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: A test giving a strange warning can make a poor user nervous. Here's a minimal patch to calm his nerves. It would be better to only give the message if python -b (not -bb) is active, but I do not know how. diff -prU2 Lib/test

[issue960325] --require feature option for configure/make (fail if building not possible)

2010-11-04 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Once upon a time, Terry J. Reedy wrote: Hallvard, do you still consider this a live issue? If this general behavior remains, yes. It's been a while since I had a computer without these libraries to test it on. (Which is why I

[issue10311] Signal handlers must preserve errno

2010-11-04 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Amaury Forgeot d'Arc writes: OTOH this is really a micro optimization. [this = only saving/restoring errno when needed] True, but practically nothing is officially safe to do in signal handlers, so it's good to avoid code which

[issue10313] Reassure user: test_os BytesWarning is OK

2010-11-04 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: R. David Murray writes: I don't see any bytes warnings when I run test_os with -b or -bb on linux on py3k trunk. (If there were such a warning and it was expected, the fix would be to capture the warning and ignore it.) Under

Re: Python documentation too difficult for beginners

2010-11-03 Thread Hallvard B Furuseth
Steven D'Aprano writes: On Tue, 02 Nov 2010 03:42:22 -0700, jk wrote: The former is difficult to find (try searching for 'open' in the search box and see what you get). A fair point -- the built-in open comes up as hit #30, whereas searching for open in the PHP page brings up fopen as hit

[issue10086] test_sysconfig failure with site-packages

2010-11-02 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: ,AC�ric Araujo writes: Attaching a patch with your two suggestions. Added file: http://bugs.python.org/file19264/fix10086.diff Not quite, since I suggested global_path.startswith(os.path.join(base, )) instead

[issue10231] SimpleHTTPRequestHandler directory bugs

2010-10-29 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: SimpleHTTPRequestHandler directory bugs Running 3.2a3 http/server.py or 2.7 SimpleHTTPServer.py as a script: * Redirection appends / to the unparsed URL instead of to the pathname component of the parsed URL: foo/dir?baz = foo

[issue10133] conn_recv_string() broken error handling

2010-10-17 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: Neither conn_recv_string() nor its callers free *newbuffer on error. The promotion rules break negative 'res' for 64-bit Py_ssize_t in the (ulength = buflength) branch: res = -1 == (UINT32)-1 == Py_ssize_t 0x instead

PEP 380 - the 'yield from' proposal

2010-10-15 Thread Hallvard B Furuseth
Regarding http://www.python.org/dev/peps/pep-0380/, Syntax for Delegating to a Subgenerator: The first call can only be .next(), there's no way to provide an initial value to .send(). That matches common use, but an initial .send() is possible if .next() was called before yield from. So I

Re: My first Python program

2010-10-14 Thread Hallvard B Furuseth
Seebs writes: You can't really rely on the destructor __del__ being called. Interesting. Do I just rely on files getting closed? Sometimes, but that's not it. Think Lisp, not C++. __del__ is not that useful. Python is garbage-collected and variables have dynamic lifetime, so the class

Re: My first Python program

2010-10-14 Thread Hallvard B Furuseth
Seebs writes: For long strings, another option is triple-quoting as you've seen in doc strings: print foo bar. I assume that this inserts a newline, though, and in this case I don't want that. True. $ python foo ... bar 'foo\nbar' foo\ ... bar 'foobar'

[issue10086] test_sysconfig failure with site-packages

2010-10-14 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: It's with 'purelib' because my prefix /site matches /site-packages. This fixes it for me, but maybe you should also assert that global_path.startswith(os.path.join(base, )). --- Lib/test/test_sysconfig.py~ 2010-09-20 +++ Lib/test

Re: My first Python program

2010-10-13 Thread Hallvard B Furuseth
Ethan Furman writes: Seebs wrote: On 2010-10-12, Hallvard B Furuseth h.b.furus...@usit.uio.no wrote: self.type, self.name = None, None Actually you can write self.type = self.name = None, though assignment statements are more limited than in C. (And I think they're assigned left-to-right

[issue10086] test_sysconfig failure with site-packages

2010-10-13 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: test_sysconfig on Python 3.2a3 fails with AssertionError: '/home/sjef/.local/lib/python3.2/site-packages' != '/home/sjef/.local/lib/python3.2/home/sjef/.local-packages' Python-3.2a3$ ./python Lib/test/regrtest.py -v

[issue10086] test_sysconfig failure with site-packages

2010-10-13 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: ./configure --prefix=/site on Ubuntu. Unedited site.py. I had Python3.2a2 installed, but removing it did not make the test do anything different. Nor did removing /home/sjef/.local/lib/python3.2, which only contained an empty site

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-12 Thread Hallvard B Furuseth
Steven D'Aprano writes: On Fri, 08 Oct 2010 22:10:35 +0200, Hallvard B Furuseth wrote: Jed Smith j...@jedsmith.org writes: a = [1, 2, 3, 4, 5, 6] a[::-1] [6, 5, 4, 3, 2, 1] Nice. Is there a trick to get a -0 index too? Other than doing 'i or len(L)' instead of 'i', that is. What

Re: My first Python program

2010-10-12 Thread Hallvard B Furuseth
Seebs writes: http://github.com/wrpseudo/pseudo/blob/master/makewrappers self.f = file(path, 'r') if not self.f: return None No. Failures tend to raise exceptions, not return error codes. Except in os.path.exists() co. $ python open(nonesuch) Traceback (most

Re: My first Python program

2010-10-12 Thread Hallvard B Furuseth
I wrote: except IOError: if e.errno != errno.ENOENT: raise# if you are picky Argh, I meant except IOError, e:. That's for Python 2 but not Python 3. except IOError as e: works on Python 2.6 and above. -- Hallvard -- http://mail.python.org/mailman/listinfo/python-list

[issue10069] 2to3 crash in fix_urllib.py

2010-10-12 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: This line: from urllib import quote as quote_url, urlencode makes 2to3 on Python 3.2a2 crash. At lib2to3/fixes/fix_urllib.py line 124, member = None. -- components: 2to3 (2.x to 3.0 conversion tool) messages: 118410

[issue10070] 2to3 wishes for already-2to3'ed files

2010-10-12 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth h.b.furus...@usit.uio.no: It would be nice with some official way to tell 2to3, Leave this code chunk alone. This is 2.* code, that is 3.* code: try: # Python 2.6 from urlparse import urlparse, urlunparse except

[issue10069] 2to3 crash in fix_urllib.py

2010-10-12 Thread Hallvard B Furuseth
Changes by Hallvard B Furuseth h.b.furus...@usit.uio.no: -- type: - crash ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10069 ___ ___ Python-bugs

[issue10070] 2to3 wishes for already-2to3'ed files

2010-10-12 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Martin v. Löwis writes: Martin v. Löwis mar...@v.loewis.de added the comment: I don't understand. If the code is already Python 3 code, why are you running 2to3 on it? I should have clarified - it's still Python 2 code (maybe

[issue10070] 2to3 wishes for already-2to3'ed files

2010-10-12 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Martin v. Löwis writes: I still don't understand. If it's 2.x code, why do you want to say that it is 3.x code? It works on Python 2. It runs on Python 3 - maybe correctly, or maybe it's not that far along yet. Maybe some

[issue10070] 2to3 wishes for already-2to3'ed files

2010-10-12 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Maybe we need to tackle this from a different angle: can you please specify the feature you are asking for exactly, with any syntax, API, or command line changes that you consider necessary? First, nothing here is necessary

[issue10070] 2to3 wishes for already-2to3'ed files

2010-10-12 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Another syntax could be attached to if-else and try-except. Given: if ...: block 1 else: block 2 or try: block 1 except ...: block 2 if 2to3 would translate block 1 to block 2

[issue10070] 2to3 wishes for already-2to3'ed files

2010-10-12 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: [I got failed issue tracker submission, trying again...] How about this phrasing: “Make 2to3 fixers not touch code in a block starting with ’if sys.version = '3'’“ (and hexversion, version_info, you get the idea)? Right, almost

Re: harmful str(bytes)

2010-10-11 Thread Hallvard B Furuseth
Terry Reedy writes: On 10/8/2010 9:31 AM, Hallvard B Furuseth wrote: That's not the point - the point is that for 2.* code which _uses_ str vs unicode, the equivalent 3.* code uses str vs bytes. Yet not the same way - a 2.* 'str' will sometimes be 3.* bytes, sometime str. So upgraded old

Re: harmful str(bytes)

2010-10-11 Thread Hallvard B Furuseth
Antoine Pitrou writes: Hallvard B Furuseth h.b.furus...@usit.uio.no wrote: Antoine Pitrou writes: Hallvard B Furuseth h.b.furus...@usit.uio.no wrote: The offender is bytes.__str__: str(b'foo') == b'foo'. It's often not clear from looking at a piece of code whether some data is treated

Re: harmful str(bytes)

2010-10-11 Thread Hallvard B Furuseth
Terry Reedy writes: On 10/8/2010 9:45 AM, Hallvard B Furuseth wrote: Actually, the implicit contract of __str__ is that it never fails, so that everything can be printed out (for debugging purposes, etc.). Nope: $ python2 -c 'str(u\u1000)' Traceback (most recent call last): File string

Re: harmful str(bytes)

2010-10-11 Thread Hallvard B Furuseth
Stefan Behnel writes: Hallvard B Furuseth, 11.10.2010 21:50: Fine, so programs will have to do it themselves... Yes, they can finally handle bytes and Unicode data correctly and safely. Having byte data turn into Unicode strings unexpectedly makes the behaviour of your code hardly predictable

Re: harmful str(bytes)

2010-10-08 Thread Hallvard B Furuseth
Arnaud Delobelle writes: Hallvard B Furuseth h.b.furus...@usit.uio.no writes: I've been playing a bit with Python3.2a2, and frankly its charset handling looks _less_ safe than in Python 2. (...) With 2.late conversion Unicode - string the equivalent operation did not silently produce garbage

Re: harmful str(bytes)

2010-10-08 Thread Hallvard B Furuseth
Antoine Pitrou writes: Hallvard B Furuseth h.b.furus...@usit.uio.no wrote: The offender is bytes.__str__: str(b'foo') == b'foo'. It's often not clear from looking at a piece of code whether some data is treated as strings or bytes, particularly when translating from old code. Which means one

Re: harmful str(bytes)

2010-10-08 Thread Hallvard B Furuseth
Steven D'Aprano writes: On Fri, 08 Oct 2010 15:31:27 +0200, Hallvard B Furuseth wrote: That's not the point - the point is that for 2.* code which _uses_ str vs unicode, the equivalent 3.* code uses str vs bytes. Yet not the same way - a 2.* 'str' will sometimes be 3.* bytes, sometime str. So

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Hallvard B Furuseth
Jed Smith j...@jedsmith.org writes: a = [1, 2, 3, 4, 5, 6] a[::-1] [6, 5, 4, 3, 2, 1] Nice. Is there a trick to get a -0 index too? Other than doing 'i or len(L)' instead of 'i', that is. L = [1,2,3,4,5] L[2:-2], L[2:-1], L[2:-0] # not quite right:-) ([3], [3, 4], []) -- Hallvard --

harmful str(bytes)

2010-10-07 Thread Hallvard B Furuseth
I've been playing a bit with Python3.2a2, and frankly its charset handling looks _less_ safe than in Python 2. The offender is bytes.__str__: str(b'foo') == b'foo'. It's often not clear from looking at a piece of code whether some data is treated as strings or bytes, particularly when translating

Python package to read .7z archives?

2010-08-04 Thread Hallvard B Furuseth
Is there an equivalent of zipfile.py for .7z archives? I have one which extracts an archive member by running 7z e -so, but that's a *slow* way to read one file at a time. Google found me some python interfaces to lzma, but apparently they only handle single compressed files, not .7z archives.

Re: Python package to read .7z archives?

2010-08-04 Thread Hallvard B Furuseth
Giampaolo Rodolà g.rod...@gmail.com writes: 2010/8/4 Hallvard B Furuseth h.b.furus...@usit.uio.no: Is there an equivalent of zipfile.py for .7z archives? I have one which extracts an archive member by running 7z e -so, but that's a *slow* way to read one file at a time. Google found me some

Re: Help to find a regular expression to parse po file

2009-07-06 Thread Hallvard B Furuseth
gialloporpora writes: I would like to extract string from a PO file. To do this I have created a little python function to parse po file and extract string: import re regex=re.compile(msgid (.*)\\nmsgstr (.*)\\n\\n) m=r.findall(s) I don't know the syntax of a po file, but this works for the

Re: [RELEASED] Python 3.1 final

2009-06-29 Thread Hallvard B Furuseth
Nobody nob...@nowhere.com writes: On Sun, 28 Jun 2009 14:36:37 +0200, Martin v. Löwis wrote: See PEP 383. Okay, that's useful, except that it may have some bugs: (...) Assuming that this gets fixed, it should make most of the problems with 3.0 solvable. OTOH, it wouldn't have killed them to

Re: [RELEASED] Python 3.1 final

2009-06-28 Thread Hallvard B Furuseth
Benjamin Peterson writes: Nobody nobody at nowhere.com writes: On Sun, 28 Jun 2009 19:21:49 +, Benjamin Peterson wrote: 1. Does Python offer any assistance in doing so, or do you have to manually convert the surrogates which are generated for unrecognised bytes? fs_encoding =

Re: No trees in the stdlib?

2009-06-26 Thread Hallvard B Furuseth
Stefan Behnel writes: João Valverde wrote: Besides some interface glitches, like returning None on delete if I recall correctly. That's actually not /that/ uncommon. Operations that change an object are not (side-effect free) functions, so it's just purity if they do not have a return value.

[issue2921] enable embedding: declare/#define only py* symbols in #includes

2009-05-16 Thread Hallvard B Furuseth
Hallvard B Furuseth h.b.furus...@usit.uio.no added the comment: Daniel Diniz writes: Would this break existing code? Source code? Not if you use the PYTHON_NAMESPACE_ONLY trick. Old programs will receive all old definitions in addition to the new autoconf symbols, since they didn't #define

Re: Python 3.0 - is this true?

2008-11-09 Thread Hallvard B Furuseth
Steven D'Aprano writes: How often do you care about equality ignoring order for lists containing arbitrary, heterogeneous types? Arbitrary, I never have. Different types of my choice, a few times. I was only interested in there being some _sort_ order (and the same in different runs of the

Re: Python 3.0 - is this true?

2008-11-09 Thread Hallvard B Furuseth
Terry Reedy writes: If you want to duplicate 2.x behavior, which does *not* work for all types... def py2key(item): return (str(type(item)), item) Nope. sorted((-1, 2, True, False)) == [-1, False, True, 2] sorted((-1, 2, True, False), key=py2key) == [False, True, -1, 2] Might

[issue2921] enable embedding: declare/#define only py* symbols in #includes

2008-05-20 Thread Hallvard B Furuseth
Hallvard B Furuseth [EMAIL PROTECTED] added the comment: Duh, I should of course have said defined(PY_HAVE_ACOSH) and not defined(HAVE_ACOSH), that was the whole point:-) And the puts() should print #define PY_HAVE_WHATEVER 1. Hopefully there are not too many #defines which would need to get

[issue2921] enable embedding: declare/#define only py* symbols in #includes

2008-05-19 Thread Hallvard B Furuseth
New submission from Hallvard B Furuseth [EMAIL PROTECTED]: It can be cumbersome to embed Python in a program which also #includes a config.h from autoconf, because Python's and the program's autoconf macros may interfere with each other. Assuming it compiles at all, both could define the same

Re: class attrdict

2007-03-09 Thread Hallvard B Furuseth
Alex Martelli writes: (...) class Namespace(object): (...) I might, if it weren't for the redundant if and the horribly buggy interference between separate instances -- which is why I wrote it, almost six years ago and without the bugs, as

Re: class attrdict

2007-03-09 Thread Hallvard B Furuseth
Alex Martelli writes: You make a good point. I do like being able to say foo.bar=baz rather than foo['bar']=baz in certain cases -- not so much to save 3 chars, but to avoid excessive punctuation; however, I don't really need this AND all of dict's power at the same time, so, I don't inherit

class attrdict

2007-03-02 Thread Hallvard B Furuseth
Does this class need anything more? Is there any risk of a lookup loop? Seems to work... class attrdict(dict): Dict where d['foo'] also can be accessed as d.foo def __init__(self, *args, **kwargs): self.__dict__ = self dict.__init__(self, *args, **kwargs) def

Re: Sorting strings containing special characters (german 'Umlaute')

2007-03-02 Thread Hallvard B Furuseth
[EMAIL PROTECTED] writes: For sorting the letter Ä is supposed to be treated like Ae, therefore sorting this list should yield l = [Aber, Ärger, Beere] Are you sure? Maybe I'm thinking of another language, I thought Ä shold be sorted together with A, but after A if the words are otherwise

Re: LDAP/LDIF Parsing

2007-02-02 Thread Hallvard B Furuseth
Bruno Desthuilliers writes: class LdapObject(object): (...) def __getattr__(self, name): try: data = self._record[name] except KeyError: raise AttributeError( object %s has no attribute %s % (self, name) ) Note that LDAP attribute

Re: LDAP/LDIF Parsing

2007-02-02 Thread Hallvard B Furuseth
Bruno Desthuilliers writes: Hallvard B Furuseth a écrit : else: # all LDAP attribs are multivalued by default, # even when the schema says they are monovalued if len(data) == 1: return data[0] else: return data[:] IMHO, this just

Re: Python regular expression question!

2006-09-20 Thread Hallvard B Furuseth
unexpected [EMAIL PROTECTED] writes: I'm trying to do a whole word pattern match for the term 'MULTX-' Currently, my regular expression syntax is: re.search(('^')+(keyword+'\\b') \b matches the beginning/end of a word (characters a-zA-Z_0-9). So that regex will match e.g. MULTX-FOO but not

Embedding python in package using autoconf

2006-05-15 Thread Hallvard B Furuseth
I want to use Python as an extension language in a package which uses autoconf. That means its and Python's autoconf #defines can conflict, so I can't safely #include both Python.h and the package's own include files:-( Do anyone have a safe way to #include at least object.h without pyconfig.h?

  1   2   >