On 2010-02-18 16:25 PM, Stephen Hansen wrote:
This has to be a stupid question, but :)
I have some generators that do stuff, then start yielding results. On
occasion, I don't want them to yield anything ever-- they're only really
generators because I want to call them /as/ a generator as part
On Thu, 18 Feb 2010 08:15:46 -0800, Steve Howell wrote:
Just to be clear, I'm not saying it's unforgivable to occasionally ship
software with bugs. It happens.
Occasionally? Oh, if only.
I would say that there probably isn't a non-trivial application in the
world that is entirely bug-free.
On Feb 18, 11:15 am, Steve Howell showel...@yahoo.com wrote:
def print_numbers()
[1, 2, 3, 4, 5, 6].map { |n|
[n * n, n * n * n]
}.reject { |square, cube|
square == 25 || cube == 64
}.map { |square, cube|
cube
}.each {
Sorry for breaking the threading, but Stephen's original post hasn't come
through to my provider.
On 2010-02-18 16:25 PM, Stephen Hansen wrote:
This has to be a stupid question, but :)
I have some generators that do stuff, then start yielding results. On
occasion, I don't want them to yield
On Feb 18, 5:08 pm, Steven D'Aprano st...@remove-this-cybersource.com.au
wrote:
On 2010-02-18 16:25 PM, Stephen Hansen wrote:
This has to be a stupid question, but :)
I have some generators that do stuff, then start yielding results. On
occasion, I don't want them to yield anything
Robert Kern robert.k...@gmail.com writes:
On 2010-02-18 16:25 PM, Stephen Hansen wrote:
The only way I can figure out how to make an empty generator is:
def gen():
# do my one-time processing here
return
yield
Is there a better way? The
I don't think it's a stupid question at all. =]. But wouldn't it solve the
problem if you call the generator the first time you need it to yield?
Cheers,
Xav
On Fri, Feb 19, 2010 at 9:30 AM, Robert Kern robert.k...@gmail.com wrote:
On Feb 18, 5:08 pm, Steven D'Aprano
On Thu, Feb 18, 2010 at 2:56 PM, Robert Kern robert.k...@gmail.com wrote:
class once(object):
def __init__(self, func, *args, **kwds):
self.func = func
self.args = args
self.kwds = kwds
def __iter__(self):
return self
def next(self):
On Thu, Feb 18, 2010 at 3:08 PM, Steven D'Aprano
st...@remove-this-cybersource.com.au wrote:
On 2010-02-18 16:25 PM, Stephen Hansen wrote:
The only way I can figure out how to make an empty generator is:
def gen():
# do my one-time processing here
return
On Thu, Feb 18, 2010 at 3:36 PM, Stephen Hansen apt.shan...@gmail.comwrote:
My motivation is clarity, I can just see a colleague a year from now asking
me, ... what the hell is return / yield? and although this is more
expensive, its less clear to me.
MORE clear to me. A class / decorator /
Jonathan Gardner jgard...@jonathangardner.net writes:
On Feb 18, 8:15 am, Steve Howell showel...@yahoo.com wrote:
def print_numbers()
[1, 2, 3, 4, 5, 6].map { |n|
[n * n, n * n * n]
}.reject { |square, cube|
square == 25 || cube == 64
On 18 Feb, 23:33, Ben Finney ben+pyt...@benfinney.id.au wrote:
[...]
No need to define functions or classes; let a generator expression take
care of it for you::
foo = (x for x in list())
foo.next()
Traceback (most recent call last):
File stdin, line 1, in module
John Bokma j...@castleamber.com writes:
Jonathan Gardner jgard...@jonathangardner.net writes:
On Feb 18, 8:15 am, Steve Howell showel...@yahoo.com wrote:
def print_numbers()
[1, 2, 3, 4, 5, 6].map { |n|
[n * n, n * n * n]
}.reject { |square, cube|
On 2/18/2010 12:28 PM, mk wrote:
Sorry to bother everyone again, but I have this problem bugging me:
#!/usr/bin/python -i
class Foo(object):
def nostat(self,val):
print val
nostat.__orig_get__ = nostat.__get__
@staticmethod
def nostatget(*args, **kwargs):
print 'args:', args, 'kwargs:',
On 2/18/2010 5:25 PM, Stephen Hansen wrote:
This has to be a stupid question, but :)
I have some generators that do stuff, then start yielding results. On
occasion, I don't want them to yield anything ever-- they're only really
generators because I want to call them /as/ a generator as part of
On 2010-02-18 17:33 PM, Ben Finney wrote:
Robert Kernrobert.k...@gmail.com writes:
On 2010-02-18 16:25 PM, Stephen Hansen wrote:
The only way I can figure out how to make an empty generator is:
def gen():
# do my one-time processing here
return
yield
Is
On Thu, 18 Feb 2010 22:11:24 -, Chris Rebert c...@rebertia.com wrote:
On Thu, Feb 18, 2010 at 11:58 AM, John Nagle na...@animats.com wrote:
snip
On that note, I went to a talk at Stanford yesterday by one of the
designers of Intel's Nelahem core. The four-core, eight thread
version is
On Thu, 2010-02-18 at 07:46 -0800, T wrote:
I have a Python app which I converted to an EXE (all files separate;
single EXE didn't work properly) via py2exe - I plan on distributing
this and would like the ability to remotely upgrade the program (for
example, via HTTP/HTTPS). Looks like it's
On 2010-02-18 17:36 PM, Stephen Hansen wrote:
On Thu, Feb 18, 2010 at 2:56 PM, Robert Kern robert.k...@gmail.com
mailto:robert.k...@gmail.com wrote:
class once(object):
def __init__(self, func, *args, **kwds):
self.func = func
self.args = args
On Thu, 18 Feb 2010 14:52:29 -, nn prueba...@latinmail.com wrote:
Wes James wrote:
I have been trying to create a list form a string. The string will be
a list (this is the contents will look like a list). i.e. [] or
['a','b']
The [] is simple since I can just check if value == [] then
Two questions:
1 - is it documented that o.__dict__[attr] is a reliable way to bypass
property methods?
2 - can one bypass a property method if the class has __slots__?
Reason: I have a couple of different flavors of request objects which I need
to make lazily conform to a standard interface. As
On Thu, 18 Feb 2010 17:30:54 -0600, Robert Kern wrote:
If all you want is a generator that doesn't yield anything, then
surely there isn't any one-time processing and you don't need the
comment?
Sure there is. Python doesn't know that nothing gets yielded until it
hits the return
Arnaud Delobelle arno...@googlemail.com writes:
What about
foo = iter('')
That doesn't return a generator.
foo = iter('')
foo
listiterator object at 0xf7cd3ed0
Whether the OP needs to create a generator, or just any iterable type,
isn't clear.
Robert Kern
On Thu, 18 Feb 2010 15:09:28 -0500, python wrote:
That's my concern - can other applications really read my temp files
created with tempfile.TemporaryFile( delete=True )?
import tempfile
x = tempfile.TemporaryFile(delete=True)
Traceback (most recent call last):
File stdin, line 1, in
On Thu, 18 Feb 2010 18:12:10 -0600, Robert Kern wrote:
He wants an iterator that executes some given side-effect-producing code
then immediately raises the StopIteration.
Ah, that's the bit I missed!
Yewww. Programming by side-effect... I hope the original poster has a
good reason for such a
On Feb 18, 3:04 pm, sjdevn...@yahoo.com sjdevn...@yahoo.com wrote:
You could do it without intermediate names or lambdas in Python as:
def print_numbers():
for i in [ cube for (square, cube) in
[(n*n, n*n*n) for n in [1,2,3,4,5,6]]
if square!=25
On Thu, 18 Feb 2010 09:50:14 -, DANNY danijel.gv...@gmail.com wrote:
If I want to have a MPEG-4/10 coded video and stream it through the
network and than have the same video on the client side, what should I
use and of course I don't want to have raw MPEG data, because than I
couldn't
On Feb 18, 1:28 am, Sreejith K sreejith...@gmail.com wrote:
On Feb 18, 1:57 pm, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
On Thu, 18 Feb 2010 00:03:51 -0800, Jonathan Gardner wrote:
On Feb 17, 10:48 pm, Sreejith K sreejith...@gmail.com wrote:
Hi everyone,
I need
On Feb 18, 6:10 pm, W. eWatson wolftra...@invalid.com wrote:
In Win7 IDLE, when I type in something with a syntax problem, a bell
rings. How do I stop that? I've looked at Control Panel Sounds, but
don't see anything of apparent use.
Monkey Patch Said: Turn off your speakers
--
On Feb 18, 3:00 pm, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
[...]
You wouldn't name your functions:
f01, f02, f03, f04, ... f99
Exactly.
(say), unless you were trying to deliberately obfuscate your code.
Anonymous functions are even more obfuscated than that. You can
Steven D'Aprano wrote:
On Thu, 18 Feb 2010 06:15:20 -0800, Steve Howell wrote:
[...]
There really ought to be a special level of Hell for people who misuse
strawman to mean a weak or invalid argument instead of what it
actually means, which is a weak or invalid argument NOT HELD by your
Brendon Wickham wrote:
On 19 February 2010 08:07, Mark Lawrence breamore...@yahoo.co.uk wrote:
Muhammad Alkarouri wrote:
Your question is borderline if not out of topic in this group. I will
make a few comments though.
This might be a Python group, but threads often drift way off topic, which
rantingrick wrote:
On Feb 18, 6:10 pm, W. eWatson wolftra...@invalid.com wrote:
In Win7 IDLE, when I type in something with a syntax problem, a bell
rings. How do I stop that? I've looked at Control Panel Sounds, but
don't see anything of apparent use.
Monkey Patch Said: Turn off your
On Feb 18, 3:04 pm, sjdevn...@yahoo.com sjdevn...@yahoo.com wrote:
On Feb 18, 11:15 am, Steve Howell showel...@yahoo.com wrote:
def print_numbers()
[1, 2, 3, 4, 5, 6].map { |n|
[n * n, n * n * n]
}.reject { |square, cube|
square == 25 || cube
Stephen Hansen wrote:
On Thu, Feb 18, 2010 at 2:56 PM, Robert Kern robert.k...@gmail.com
mailto:robert.k...@gmail.com wrote:
class once(object):
def __init__(self, func, *args, **kwds):
self.func = func
self.args = args
self.kwds = kwds
Steve Howell showel...@yahoo.com writes:
But frankly, although there's no reason that you _have_ to name the
content at each step, I find it a lot more readable if you do:
def print_numbers():
tuples = [(n*n, n*n*n) for n in (1,2,3,4,5,6)]
filtered = [ cube for (square, cube) in
Steven,
Thank you very much for your wonderful reply!!
I had read the Fine Manual, but as you pointed out the documentation
only mentions visibility of file names.
Exclusive locks are advisory, not mandatory, on some operating systems, so
you can't rely on it.
That comment and your list
On Feb 18, 10:58 pm, Paul Rubin no.em...@nospam.invalid wrote:
Steve Howell showel...@yahoo.com writes:
But frankly, although there's no reason that you _have_ to name the
content at each step, I find it a lot more readable if you do:
def print_numbers():
tuples = [(n*n, n*n*n) for n
On Feb 18, 7:19 pm, Ryan Kelly r...@rfk.id.au wrote:
On Thu, 2010-02-18 at 07:46 -0800, T wrote:
I have a Python app which I converted to an EXE (all files separate;
single EXE didn't work properly) via py2exe - I plan on distributing
this and would like the ability to remotely upgrade the
On Feb 18, 2:49 pm, Jonathan Gardner jgard...@jonathangardner.net
wrote:
On Feb 18, 8:15 am, Steve Howell showel...@yahoo.com wrote:
def print_numbers()
[1, 2, 3, 4, 5, 6].map { |n|
[n * n, n * n * n]
}.reject { |square, cube|
square == 25
On Feb 18, 7:58 pm, Paul Rubin no.em...@nospam.invalid wrote:
Steve Howell showel...@yahoo.com writes:
But frankly, although there's no reason that you _have_ to name the
content at each step, I find it a lot more readable if you do:
def print_numbers():
tuples = [(n*n, n*n*n) for n
I've read the documentation on compileall and tried using this
module directly.
Nowhere can I find how to specify to compileall that it should
create .pyo vs. .pyc files.
Goal: I would like to use the compileall.compile_dir() method to
generate -OO type .pyo files as part of a larger Python
On Feb 18, 8:27 pm, sjdevn...@yahoo.com sjdevn...@yahoo.com wrote:
On Feb 18, 10:58 pm, Paul Rubin no.em...@nospam.invalid wrote:
Steve Howell showel...@yahoo.com writes:
But frankly, although there's no reason that you _have_ to name the
content at each step, I find it a lot more
Hi,
I've got some text to parse that looks like this
text = ''' blah blah blah
\Template[Name=RAD,LMRB=False,LMRG=True]{tables}
ho dee ho
'''
I want to extract the bit between the brackets and create a dictionary.
Here's what I'm doing now:
def options(text):
d = dict()
options =
John Nagle wrote:
One way to implement locking is something like this:
Mutable objects have a reference count field, a lock field,
and an owner field. Initially, the owner of an object is its thread.
If an object's only reference is a field of a synchronized object, the
owner is the
On Thu, Feb 18, 2010 at 10:46 PM, Steve Howell showel...@yahoo.com wrote:
On Feb 18, 2:49 pm, Jonathan Gardner jgard...@jonathangardner.net
wrote:
On Feb 18, 8:15 am, Steve Howell showel...@yahoo.com wrote:
def print_numbers()
[1, 2, 3, 4, 5, 6].map { |n|
[n *
On Feb 18, 7:58 pm, Paul Rubin no.em...@nospam.invalid wrote:
Steve Howell showel...@yahoo.com writes:
But frankly, although there's no reason that you _have_ to name the
content at each step, I find it a lot more readable if you do:
def print_numbers():
tuples = [(n*n, n*n*n) for n
Steve Howell showel...@yahoo.com writes:
http://haskell.org/ghc/docs/6.10.4/html/users_guide/syntax-extns.html...
might be of interest. Maybe Ruby and/or Python could grow something similar.
Can you elaborate?
List comprehensions are a Python feature you're probably familiar with,
and I think
On Thu, 18 Feb 2010 22:48:21 -0500, Steve Holden wrote:
Next week: Lesson 2 - Ad Hominem Attacks
I wouldn't pay any attention to Steve, all Stevens are notorious liars.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
Steve Howell wrote:
Python may not support the broadest notion of anonymous functions, but
it definitely has anonymous blocks. You can write this in Python:
for i in range(10):
print i
print i * i
print i * i * i
There's a clear difference between this and a Ruby
On Thu, 18 Feb 2010 19:57:35 -0800, Steve Howell wrote:
The names you give to the intermediate results here are terse--tuples
and filtered--so your code reads nicely.
In a more real world example, the intermediate results would be
something like this:
departments
On Feb 18, 9:41 pm, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
On Thu, 18 Feb 2010 22:48:21 -0500, Steve Holden wrote:
Next week: Lesson 2 - Ad Hominem Attacks
I wouldn't pay any attention to Steve, all Stevens are notorious liars.
--
Steven
Especially when their last
On Thu, 18 Feb 2010 21:34:58 -0800, Dennis Lee Bieber wrote:
On Thu, 18 Feb 2010 15:09:28 -0500, pyt...@bdurham.com declaimed the
following in gmane.comp.python.general:
2. As soon as my process terminates (voluntarily or involuntarily), the
temp file gets deleted.
Which only means
On Fri, 19 Feb 2010 18:52:20 +1300, Gregory Ewing wrote:
The Ruby approach has the advantage of making it possible to implement
user-defined control structures without requiring a macro facility. You
can't do that in Python.
[...]
Also, most people who advocate adding some form of
On Feb 18, 9:46 pm, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
On Thu, 18 Feb 2010 19:57:35 -0800, Steve Howell wrote:
The names you give to the intermediate results here are terse--tuples
and filtered--so your code reads nicely.
In a more real world example, the
On 2010-02-18 19:28 PM, Mel wrote:
Steven D'Aprano wrote:
On Thu, 18 Feb 2010 17:30:54 -0600, Robert Kern wrote:
If all you want is a generator that doesn't yield anything, then
surely there isn't any one-time processing and you don't need the
comment?
Sure there is. Python
On 2010-02-18 18:33 PM, Ben Finney wrote:
Robert Kernrobert.k...@gmail.com writes:
He doesn't want *any* empty generator. He wants an iterator that
executes some given side-effect-producing code then immediately raises
the StopIteration.
Ah, hm. That's a rather perverse use case, but I'm
On Fri, 19 Feb 2010 00:15:20 -0600, Robert Kern wrote:
What's the point of the wheel spinning? Did I miss something?
I wonder whether it's for some kind of framework with a main loop like
for it in list_of_iterables:
for x in it:
do_this_or_that (x)
where, every once in a
On Feb 18, 9:37 pm, Kurt Smith kwmsm...@gmail.com wrote:
On Thu, Feb 18, 2010 at 10:46 PM, Steve Howell showel...@yahoo.com wrote:
On Feb 18, 2:49 pm, Jonathan Gardner jgard...@jonathangardner.net
wrote:
On Feb 18, 8:15 am, Steve Howell showel...@yahoo.com wrote:
def print_numbers()
Robert Kern robert.k...@gmail.com writes:
On 2010-02-18 18:33 PM, Ben Finney wrote:
Robert Kernrobert.k...@gmail.com writes:
He doesn't want *any* empty generator. He wants an iterator that
executes some given side-effect-producing code then immediately
raises the StopIteration.
PiCloud, a cloud-computing platform for the Python Programming Language, has
released version 1.8 of its client library, cloud. PiCloud enables Python
users to leverage the power of an on-demand, high performance, and auto
scaling compute cluster with as few as three lines of code! No server
On Feb 18, 9:52 pm, Gregory Ewing greg.ew...@canterbury.ac.nz wrote:
Steve Howell wrote:
Python may not support the broadest notion of anonymous functions, but
it definitely has anonymous blocks. You can write this in Python:
for i in range(10):
print i
print i * i
Hi. The with statement is certainly nifty. The trouble is, the
*only* two documented examples how it can be used with the library
classes are file objects (which I use all the time) and thread locks
which I almost never use. Yet there are many, many classes in the
library whose use would be
Ezio Melotti ezio.melo...@gmail.com added the comment:
Ported to py3k in r78214. I will think about the cleanups later, they are not
so important right now.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7712
Florent Xicluna la...@yahoo.fr added the comment:
Still an issue for some buildbot:
http://www.python.org/dev/buildbot/all/builders/x86%20XP-4%203.x/builds/1487
http://www.python.org/dev/buildbot/all/builders/x86%20XP-4%203.x/builds/1491
It is loosely related with #7712, because now the tests
New submission from Michael Newman michael.b.new...@gmail.com:
The attached example unit test file shows that assertDictContainsSubset cannot
handle error messages that need to show integer keys. Below is the output of
the test suite, where test_mixed_keys_fail has an error (code mistake),
Paul Boddie p...@boddie.org.uk added the comment:
Actually, in the issue reported, the initial problem occurs in the evaluation
of an object in a boolean context (and the subsequent problem occurs with an
explicit len invocation):
Stefan Krah stefan-use...@bytereef.org added the comment:
It looks good (I agree on number_class), but I'd change these:
- Add raiseit=True to context.copy_decimal()
- Remove wrong comment from context.is_infinite()
- Add _convert_other(a, raiseit=True) to context.logical_invert()
-
Ezio Melotti ezio.melo...@gmail.com added the comment:
Also the test has a few problems:
1) the keys of known_locales are lowercase, but locale_encoding =
locale.getpreferredencoding() can return uppercase encodings (e.g. UTF-8);
2) this masks another error: the b'\xe4' is not a valid utf-8
Christoph Neuroth christoph.neur...@googlemail.com added the comment:
You're right, that has been improved in regard to how you can do it instead.
However, I still think it lacks to mention the security risk involved - compare
this to e.g. os.tempnam(), which has a warning in a red box.
Eric Smith e...@trueblade.com added the comment:
If you want to generate some more discussion, I suggest you close this issue
and reopen the other one, since that has more people on the nosy list.
--
___
Python tracker rep...@bugs.python.org
Christoph Neuroth christoph.neur...@googlemail.com added the comment:
Good idea :)
--
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7950
___
Christoph Neuroth christoph.neur...@googlemail.com added the comment:
As recommended by eric.smith on #7950, I'd like to suggest further extending
the documentation to include a security warning about (quite easily) possible
code injection bugs when using the shell=True parameter (similar to
Mark Dickinson dicki...@gmail.com added the comment:
Tweaked some doctests in r78218:
- add integer argument doctest for logical_invert
- fix integer literals with a leading zero for the other logical_***
methods, since they're illegal in Python 3.
Merged to py3k in r78219.
Thanks,
Ronald Oussoren ronaldousso...@mac.com added the comment:
That's odd, they should exist and do for me:
Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type help, copyright, credits or license for more information.
import sys
sys.ps1
' '
New submission from Mark Dickinson dicki...@gmail.com:
With a 64-bit debug non-framework builds of the trunk and py3k, on OS X 10.6,
I'm consistently getting the following failure in test_platform:
trunk dickinsm$ ./python.exe Lib/test/regrtest.py -uall test_platform
test_platform
[18064 refs]
Lucian Ursu lucian_u...@yahoo.com added the comment:
Then it must be an issue with my Python. This is what I get.
import sys
dir(sys)
['__displayhook__', '__doc__', '__excepthook__', '__name__', '__package__',
'__stderr__', '__stdin__', '__stdout__', '_clear_type_cache',
'_current_frames',
Ronald Oussoren ronaldousso...@mac.com added the comment:
This test seems to trigger an issue in site.py, adding '-v' to the code that
starts the interpreter in test_platform.py gives the following output (amongst
a lot more text that doesn't seem to be relevant):
'import site' failed;
Martin v. Löwis mar...@v.loewis.de added the comment:
The problem is that the version number goes into the MSI ProductVersion
property, which MUST be numeric, or else Windows will refuse to install the
package. So this is not just an arbitrary choice (at least not by bdist_msi).
I'm not sure
Martin v. Löwis mar...@v.loewis.de added the comment:
Closing because of lack of feedback.
--
nosy: +loewis
resolution: - out of date
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5839
Andrew McNabb amcn...@mcnabbs.org added the comment:
This seems like a common need (particularly for stdout and stderr), and setting
`stdout._CHUNK_SIZE = 1` is relying on an implementation detail.
1) Can the documentation for TextIOWrapper be updated to clearly describe this
extra buffering
Antoine Pitrou pit...@free.fr added the comment:
I agree this deserves documentation. I'm not convinced it's a common need,
though. Usually you either use stdin/stdout in binary mode or in text mode, but
you don't interleave both quite frequently.
--
assignee: - georg.brandl
Andrew McNabb amcn...@mcnabbs.org added the comment:
I would imagine that this would come up in most programs that read data from a
pipe or from a socket (which are binary data) and then output to stdout or
stderr. I ran across the problem in my first non-trivial port to Python 3, and
it
Jeremy Hylton jhyl...@gmail.com added the comment:
I'm trying to figure out the attached script. If I run Python 3.0, the script
doesn't run because of the undefined gc.DEBUG_OBJECTS. If I just remove that,
the script runs without error. Does that mean the problem is fixed? Or is
running
Eric Smith e...@trueblade.com added the comment:
At the language summit we okay'd using ctypes in the tests for standard lib
modules, specifically for this issue.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1578269
Michael Foord mich...@voidspace.org.uk added the comment:
Thanks for reporting this.
I can fix this particular error easily by repr'ing the keys. In the process
I've found another fun way of killing this assert method:
one = ''.join(chr(i) for i in range(255))
two = u'\uFFFD'
New submission from Thomas Heller thel...@ctypes.org:
This little script 'ctypes-leak.py' leaks memory:
import gc
from ctypes import *
PROTO = WINFUNCTYPE(None)
class Test(object):
def func(self):
pass
def __init__(self):
self.v = PROTO(self.func)
while 1:
try:
New submission from Michael Newman michael.b.new...@gmail.com:
test.support.captured_output is not covered in the online documents:
http://docs.python.org/3.1/library/test.html
http://docs.python.org/dev/py3k/library/test.html
However, it does have a docstring in C:\Python31\Lib\test\support.py
Mark Dickinson dicki...@gmail.com added the comment:
Specifically, the behaviour comes from an early check for empty strings in the
PyUnicode_FromEncodedObject function:
/* Convert to Unicode */
if (len == 0) {
Py_INCREF(unicode_empty);
v = (PyObject *)unicode_empty;
Raymond Hettinger rhettin...@users.sourceforge.net added the comment:
Will ponder this a bit more but will likely close this specific request
(leaving open the possibility of a more general rewrite of pprint).
--
assignee: - rhettinger
priority: - low
versions: +Python 2.7, Python
Ori Avtalion o...@avtalion.name added the comment:
OK.
The attached patch removes the empty string check before decoding.
I'm not sure where tests should go, since I can only find them in Lib/test/ and
this is not a library change.
--
keywords: +patch
Added file:
Alexander Belopolsky alexander.belopol...@gmail.com added the comment:
I wonder: with year bounds being checked in gettmarg() and mktime accepting
arbitrary values for the rest of the tm structure members (at least it appears
to on my Mac), is it possible trigger mktime argument out of range?
Mark Dickinson dicki...@gmail.com added the comment:
Thanks for the patch.
Rather than remove that optimization entirely, I'd consider pushing it into
PyUnicode_Decode.
All tests (whether for the standard library or for the core) go into Lib/test,
so that would be the right place.
Mark Dickinson dicki...@gmail.com added the comment:
I take that back: test_codecs_errors isn't the right function to add these
tests to. I actually don't see any current tests for invalid codecs. Part of
the problem would be coming up with an invalid codec name in the first place:
as I
Mark Dickinson dicki...@gmail.com added the comment:
And PyUnicode_Decode doesn't look up the encoding in the registry either:
that's somewhere in PyCodec_Decode.
I'm going to butt out now and leave this to those who know the code better. :)
--
Ori Avtalion o...@avtalion.name added the comment:
Ignoring the custom utf-8/latin-8 conversion functions, the actual checking if
a codec exists is done in Python/codecs.c's PyCodec_Decode.
Is that where I should move the aforementioned optimization to?
Is it safe to assume that the decoded
Alexander Belopolsky alexander.belopol...@gmail.com added the comment:
Victor,
As you explain in your own documentation, the proposed method is equivalent to
``(time.mktime(self.timetuple()), self.microsecond)``, so all it does is
replacing a less than a one-liner. Moreover, I am not sure
New submission from Alexander Belopolsky alexander.belopol...@gmail.com:
object(1)
Traceback (most recent call last):
File stdin, line 1, in module
TypeError: object.__new__() takes no parameters
This is misleading because object.__new__() takes one parameter:
object.__new__(object)
Vlastimil Brom vlastimil.b...@gmail.com added the comment:
Thanks for fixing the argument positions;
unfortunately, it seems, there might be some other problem, that makes my code
work differently than the builtin re;
it seems, in the character classes the ignorcase flag is ignored somehow:
Phillip J. Eby p...@telecommunity.com added the comment:
What sort of test did you have in mind? To test the desired outcome, it seems
we'd need to poison os.environ, reload wsgiref.handlers, remove the poison, and
then make sure it didn't get in. That seems a bit like overkill (as well as
101 - 200 of 208 matches
Mail list logo