[issue1542677] IDLE shell gives different len() of unicode strings compared to Python shell
Santiago Gala sg...@apache.org added the comment: Updating the components as the error surfaces in the compile builtin. the compile builtin works when given unicode, but fails when using a utf8 (local input encoding) string. Rather than adding a coding string to compile, my guess is that compile should be fixed or fed a unicode string. See the effects on the shell: print len('à') 2 print len(u'à') 1 exec compile(print len('à'),'test', 'single') 2 exec compile(print len(u'à'),'test', 'single') 2 exec compile(print len('à').decode(utf8),'test', 'single') 2 exec compile(print len(u'à').decode(utf8),'test', 'single') 1 So the error disappears when the string fed to exec compile is properly decoded to unicode. In idlelib there is an attempt to encode the input to IOBindings.encoding, but IOBindings.encoding is broken here, as locale.nl_langinfo(locale.CODESET) gives 'ANSI_X3.4-1968', which looks up as 'ascii', while locale.getpreferredencoding() gives 'UTF-8' (as it should). If I comment the whole attempt, idle works (for this test, not fully tested): sg...@marlow ~ $ diff -u /tmp/PyShell.py /usr/lib64/python2.6/idlelib/PyShell.py --- /tmp/PyShell.py 2009-04-12 11:01:01.0 +0200 +++ /usr/lib64/python2.6/idlelib/PyShell.py 2009-04-12 10:59:16.0 +0200 @@ -592,14 +592,14 @@ self.more = 0 self.save_warnings_filters = warnings.filters[:] warnings.filterwarnings(action=error, category=SyntaxWarning) -if isinstance(source, types.UnicodeType): -import IOBinding -try: -source = source.encode(IOBinding.encoding) -except UnicodeError: -self.tkconsole.resetoutput() -self.write(Unsupported characters in input\n) -return +#if isinstance(source, types.UnicodeType): +#import IOBinding +#try: +#source = source.encode(IOBinding.encoding) +#except UnicodeError: +#self.tkconsole.resetoutput() +#self.write(Unsupported characters in input\n) +#return try: # InteractiveInterpreter.runsource() calls its runcode() method, # which is overridden (see below) print len('á') 2 print len(u'á') 1 print 'á' á print u'á' á Now using Python 2.6.1 (r261:67515, Apr 10 2009, 14:34:00) on x86_64 -- components: +Interpreter Core ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1542677 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5740] multiprocessing.connection.Client API documentation incorrect
New submission from Garrett Cooper yaneg...@gmail.com: In the API for connections.Client, it says: multiprocessing.connection.Client(address[, family[, authenticate[, authkey]]]) In the final paragraph is says: `If authentication is True or authkey ' As per the API provided it should be: `If authenticate is True or authkey ' This is true for the 2.6.1 and 3.1 documentation, so I assume it's incorrect for the 2.7 and 3.0 documentation as well. -- assignee: georg.brandl components: Documentation messages: 85887 nosy: georg.brandl, jnoller, yaneurabeya severity: normal status: open title: multiprocessing.connection.Client API documentation incorrect versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5740 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5736] Add the iterator protocol to dbm modules
Akira Kitada akit...@gmail.com added the comment: Here's another patch which addsd iter to dbm and gdbm. Note that dbm and gdbm C API is a little different. gdbm_nextkey requires key for its argument, dbm_nextkey don't. So I had to use for gdbm an static variable that points to the current position. Now iterator in gdbm and dbm works differently. import dbm d = dbm.open('foo', 'n') d['k1'] = 'v1';d['k2'] = 'v2'; for i in d: print i; break ... k1 for i in d: print i ... k2 for i in d: print i ... import gdbm gd = gdbm.open('foo.gdbm', 'n') gd['k1'] = 'v1';gd['k2'] = 'v2'; for i in gd: print i; break ... k2 for i in gd: print i for i in gd: print i ... k1 for i in gd: print i ... k2 k1 -- Added file: http://bugs.python.org/file13676/issue5736.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5736 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5736] Add the iterator protocol to dbm modules
Akira Kitada akit...@gmail.com added the comment: Of course iter should work in the same way in all dbm modules. iter in dbm/gdbm should work like dumbdbm's iter. dumb = dumbdbm.open('foo', 'n') dumb['k1'] = 'v1';dumb['k2'] = 'v2'; for i in dumb: print i; break ... k2 for i in dumb: print i for i in dumb: print i ... k2 k1 for i in dumb: print i for i in dumb: print i ... k2 k1 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5736 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1542677] IDLE shell gives different len() of unicode strings compared to Python shell
Naoki INADA songofaca...@gmail.com added the comment: utf-8 is not locale encoding. f = open('á.txt') If this line compiled into utf-8 and locale encoding is not utf-8, can't open 'á.txt'. IMHO, in case of Python 2.x, correct approach is fix IOBindings.encoding and compile() with pep0263. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1542677 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5700] io.FileIO calls flush() after file closed
Changes by Brian Quinlan br...@sweetapp.com: Added file: http://bugs.python.org/file13677/cooperation.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5700 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5700] io.FileIO calls flush() after file closed
Brian Quinlan br...@sweetapp.com added the comment: cooperation.diff: - change the close method to call .flush() and then ._close() - only IOBase implements close() (though a subclass can override close without causing problems - so long as it calls super().close()) - .flush() invokes super().flush() - ._close() invokes super()._close() - FileIO is implemented in Python in _pyio.py so that it can have the same base class as the other Python-implemented files classes - tests verify that .flush() is not called after the file is closed - tests verify that ._close()/.flush() calls move correctly are propagated correctly -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5700 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1542677] IDLE shell gives different len() of unicode strings compared to Python shell
Naoki INADA songofaca...@gmail.com added the comment: How to use locale.getpreferredencoding() instead of locale.nl_langinfo(locale.CODESET). --- IOBinding.py.back Sun Apr 12 19:54:52 2009 +++ IOBinding.pySun Apr 12 20:02:58 2009 @@ -35,40 +35,16 @@ # Encoding for file names filesystemencoding = sys.getfilesystemencoding() -encoding = ascii -if sys.platform == 'win32': -# On Windows, we could use mbcs. However, to give the user -# a portable encoding name, we need to find the code page -try: -encoding = locale.getdefaultlocale()[1] -codecs.lookup(encoding) -except LookupError: -pass -else: -try: -# Different things can fail here: the locale module may not be -# loaded, it may not offer nl_langinfo, or CODESET, or the -# resulting codeset may be unknown to Python. We ignore all -# these problems, falling back to ASCII -encoding = locale.nl_langinfo(locale.CODESET) -if encoding is None or encoding is '': -# situation occurs on Mac OS X -encoding = 'ascii' -codecs.lookup(encoding) -except (NameError, AttributeError, LookupError): -# Try getdefaultlocale well: it parses environment variables, -# which may give a clue. Unfortunately, getdefaultlocale has -# bugs that can cause ValueError. -try: -encoding = locale.getdefaultlocale()[1] -if encoding is None or encoding is '': -# situation occurs on Mac OS X -encoding = 'ascii' -codecs.lookup(encoding) -except (ValueError, LookupError): -pass +encoding = utf-8 -encoding = encoding.lower() +preferredencoding = None +try: +preferredencoding = locale.getpreferredencoding() +codecs.lookup(preferredencoding) +encoding = preferredencoding.lower() +except LookupError: +pass +del preferredencoding coding_re = re.compile(coding[:=]\s*([-\w_.]+)) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1542677 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2725] Handle ASDLSyntaxErrors gracefully
Georg Brandl ge...@python.org added the comment: Committed a similar patch in r71505. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2725 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5700] io.FileIO calls flush() after file closed
Antoine Pitrou pit...@free.fr added the comment: - FileIO is implemented in Python in _pyio.py so that it can have the same base class as the other Python-implemented files classes Is it really necessary (e.g. to pass the tests)? -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5700 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5706] setuptools doesn't honor standard compiler variables
Changes by Georg Brandl ge...@python.org: -- assignee: - tarek nosy: +tarek ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5706 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5700] io.FileIO calls flush() after file closed
Brian Quinlan br...@sweetapp.com added the comment: - FileIO is implemented in Python in _pyio.py so that it can have the same base class as the other Python-implemented files classes Is it really necessary (e.g. to pass the tests)? It is necessary to make MI work. With out it the inheritance graph looks like this (using _pyio): io.IOBase_pyio.IOBase | | io.FileIO MyMixin | | \/ \ / \/ MyClass If you call MyClass.flush() with this hierarchy then it will propagate to io.IOBase. Since io.IOBase doesn't call super().flush() in its flush implementation (because it has no super class), flush propagation would stop and MyMixin.flush wouldn't be called. There are other ways you could solve this, of course, like getting io.IOBase to call super().flush and ignore any errors that it gets. But it seems like this is the right way to fix this problem anyway - as a user, I would expect isinstance(FileIO(...), IOBase) but that is not currently the case with _pyio. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5700 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5708] Tiny code polishing to unicode_repeat
Georg Brandl ge...@python.org added the comment: Committed in r71506. -- resolution: - accepted status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5708 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5704] Command line option '-3' should imply '-t'
Georg Brandl ge...@python.org added the comment: Added in r71507. -- resolution: - accepted status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5704 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5665] Add more pickling tests
Benjamin Peterson benja...@python.org added the comment: Ok. Thank you! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5665 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1720250] PyGILState_Ensure does not acquires GIL
Changes by Georg Brandl ge...@python.org: -- assignee: georg.brandl - ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1720250 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5741] SafeConfigParser incorrectly detects lone percent signs
New submission from Márcio Faustino m.faust...@gmail.com: The SafeConfigParser class incorrectly detects lone percent signs, for example, it doesn't accept 100%% as a valid value. The cause of this is the _badpercent_re regular expression: - The first alternative %[^%] fails with the string %%_, because it matches %_. - The second alternative %$ fails with the string %%, because it matches %. --- from ConfigParser import * SafeConfigParser().set('DEFAULT', 'test', '100%%') -- components: Library (Lib) messages: 85899 nosy: marcio severity: normal status: open title: SafeConfigParser incorrectly detects lone percent signs type: behavior versions: Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5700] io.FileIO calls flush() after file closed
Antoine Pitrou pit...@free.fr added the comment: It is necessary to make MI work. With out it the inheritance graph looks like this (using _pyio): io.IOBase_pyio.IOBase | | io.FileIO MyMixin | | \/ \ / \/ MyClass MyMixin doesn't need to inherit from IOBase, since precisely it is a mixin. It's just a piece of functionality that you drop into an already existing inheritance tree. But it seems like this is the right way to fix this problem anyway - as a user, I would expect isinstance(FileIO(...), IOBase) but that is not currently the case with _pyio. That's because the reference ABCs are defined in the io module, not in _pyio: True issubclass(_pyio.FileIO, io.IOBase) True issubclass(io.TextIOWrapper, io.IOBase) True issubclass(_pyio.TextIOWrapper, io.IOBase) True _pyio.IOBase and friends are just concrete implementations of those ABCs: True issubclass(_pyio.TextIOBase, io.TextIOBase) True I know it looks a bit non-intuitive at first, but the point is that the ABCs are unified, even there are two different implementations. I think it's better than having two different sets of ABCs depending on whether you import the pure-Python version or the C version. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5700 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5700] io.FileIO calls flush() after file closed
Brian Quinlan br...@sweetapp.com added the comment: Antoine Pitrou wrote: Antoine Pitrou pit...@free.fr added the comment: It is necessary to make MI work. With out it the inheritance graph looks like this (using _pyio): io.IOBase_pyio.IOBase | | io.FileIO MyMixin | | \/ \ / \/ MyClass MyMixin doesn't need to inherit from IOBase, since precisely it is a mixin. It's just a piece of functionality that you drop into an already existing inheritance tree. In my implementation, it does. Otherwise the linearization of the class hierarchy becomes: MyClass - io.FileIO - io.IOBase - MyMixin (- _pyio.IOBase) But io.IOBase doesn't make super calls so MyMixin method won't be called. I think that this linearization is probably more useful: MyClass - io.FileIO - MyMixin - IOBase And you get that when io.FileIO and MyMixin share the same IOBase as a base class. I don't mind changing io.IOBase to make super calls in ._close() and .flush() and suppressing the attributes errors that will be generated if a mixin is not present - but it feels a bit untidy to me. [snipped] I know it looks a bit non-intuitive at first, but the point is that the ABCs are unified, even there are two different implementations. I think it's better than having two different sets of ABCs depending on whether you import the pure-Python version or the C version. I'm not trying to change the ABC unification at all - and if I did then there is a bug in my code. I just think that the immediate parent class of _pyio.FileIO should be _pyio.IOBase (just like _io.FileIO has _io.IOBase as an immediate parent). That will make the Python and C class hierarchies completely consistent within themselves. Cheers, Brian -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5700 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5740] multiprocessing.connection.Client API documentation incorrect
Jesse Noller jnol...@gmail.com added the comment: Will fix tomorrow -- assignee: georg.brandl - jnoller ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5740 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5700] io.FileIO calls flush() after file closed
Antoine Pitrou pit...@free.fr added the comment: I think that this linearization is probably more useful: MyClass - io.FileIO - MyMixin - IOBase But why not simply: MyClass - MyMixin - io.FileIO - IOBase ? Is there something I'm missing that prevents you from doing this? I'm not trying to change the ABC unification at all - and if I did then there is a bug in my code. I just think that the immediate parent class of _pyio.FileIO should be _pyio.IOBase (just like _io.FileIO has _io.IOBase as an immediate parent). That will make the Python and C class hierarchies completely consistent within themselves. I understand, but that's at the price of an otherwise useless indirection layer, which will also make _pyio even slower that it already is :-) (I admit, however, that _pyio shouldn't be used in normal circumstances, so this is not a showstopper argument) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5700 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5675] string module requires bytes type for maketrans, but calling method on regular string does not
Georg Brandl ge...@python.org added the comment: This is (kind of) intentional. string.maketrans operates on bytes, not string objects. However, this is quite confusing, so I added bytes.maketrans() now in py3k, and deprecated string.maketrans(). (r71521) -- resolution: - works for me status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5675 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4799] handling inf/nan in '%f'
Eric Smith e...@trueblade.com added the comment: I believe this is a duplicate of issue 4482. I'm closing this and will add everyone who is nosy on this to be nosy on 4482. -- resolution: - duplicate status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4799 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4482] 10e667.__format__('+') should return 'inf'
Eric Smith e...@trueblade.com added the comment: This is a duplicate of 4799, which I've closed. I've resisted fixing this because differences in various platform sprintf's have made it difficult. Now that Mark Dickinson and I are close to removing the use of sprintf for float formatting, I'll have the tools to deal with this better. Not sure what this means for 2.7, yet. We're not planning on backporting the new float formatting to 2.7. -- nosy: +cdavid, cito, marketdickinson versions: -Python 2.6, Python 3.0 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4482 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4482] 10e667.__format__('+') should return 'inf'
Eric Smith e...@trueblade.com added the comment: Actually this isn't quite a duplicate of 4799, but it's close. Any fix to this issue will also address 4799's original report: On windows, with python 2.6, s = '%s' % float('inf') is 'inf', but s ='%f' % float('inf') is equal to '1.#INF'. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4482 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5515] 'n' formatting for int and float handles leading zero padding poorly
Eric Smith e...@trueblade.com added the comment: This won't get fixed in 3.0 or 2.6. Still not sure about 2.7, but I'm considering how to fix it there. -- versions: -Python 2.6, Python 3.0 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5515 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3382] Make '%F' and float.__format__('F') convert results to upper case.
Changes by Eric Smith e...@trueblade.com: -- nosy: +marketdickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3382 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4482] 10e667.__format__('+') should return 'inf'
Daniel Stutzbach dan...@stutzbachenterprises.com added the comment: The patch I submitted adds a special-case for inf/-inf/NaN so that sprintf is avoided for those values. Should work on any platform, I believe. I'm not sure how it interacts with your 3.x plans. Seems like it would be a good patch for 2.7 at least, though. (and the patch that adds tests should go into both 2.7 and 3.x) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4482 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4482] 10e667.__format__('+') should return 'inf'
Eric Smith e...@trueblade.com added the comment: Agreed. That might be the strategy for 2.7. But it depends on how much of the other float and int formatting code I can re-use from 3.1. If I can hide the 2.7/3.1 differences in PyOS_double_to_string, then the 2.7 and 3.1 code should be identical, and the fix will be different in the 3.1 code base. I'll decide in the next few weeks. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4482 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5741] SafeConfigParser incorrectly detects lone percent signs
Georg Brandl ge...@python.org added the comment: Should be fixed in r71537. Will backport to 2.6. -- nosy: +georg.brandl resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4501] asyncore's urgent data management and connection closed events are broken when using poll()
R. David Murray rdmur...@bitdance.com added the comment: Fixed as part of the work done on issue1161031. -- nosy: +r.david.murray resolution: - duplicate stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4501 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5700] io.FileIO calls flush() after file closed
Brian Quinlan br...@sweetapp.com added the comment: Antoine Pitrou wrote: Antoine Pitrou pit...@free.fr added the comment: I think that this linearization is probably more useful: MyClass - io.FileIO - MyMixin - IOBase But why not simply: MyClass - MyMixin - io.FileIO - IOBase ? Is there something I'm missing that prevents you from doing this? No, doing this is trivial. But shouldn't it be up to the implementor of MyClass to decide whether MyMixin or io.FileIO methods are evaluated first? I'm not trying to change the ABC unification at all - and if I did then there is a bug in my code. I just think that the immediate parent class of _pyio.FileIO should be _pyio.IOBase (just like _io.FileIO has _io.IOBase as an immediate parent). That will make the Python and C class hierarchies completely consistent within themselves. I understand, but that's at the price of an otherwise useless indirection layer, which will also make _pyio even slower that it already is :-) Maybe I misunderstand the purpose of _pyio. The Python 3.1 says that its purpose is for experimentation. For experimentation, having a Python implementation where you can add methods and change behavior (though perhaps not in as deep as way is if this class were completely written in Python) is useful. It is also useful for the behavior of the Python implementation to match that of the C implementation as closely as possible - this patch makes the inheritance graph for _pyio.FileIO more consistent. I, for example, want to add a sync() method to FileIO that will call fsync() on the file's file descriptor. With this change, I have a place to plug in that change in Python and I can write the C implementation when I have the Python implementation right. Cheers, Brian -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5700 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5700] io.FileIO calls flush() after file closed
Antoine Pitrou pit...@free.fr added the comment: No, doing this is trivial. But shouldn't it be up to the implementor of MyClass to decide whether MyMixin or io.FileIO methods are evaluated first? Is there a concrete use case, though? By the way, what if _pyio.FileIO inherited from io.FileIO instead of delegating all methods? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5700 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5700] io.FileIO calls flush() after file closed
Brian Quinlan br...@sweetapp.com added the comment: Antoine Pitrou wrote: Antoine Pitrou pit...@free.fr added the comment: No, doing this is trivial. But shouldn't it be up to the implementor of MyClass to decide whether MyMixin or io.FileIO methods are evaluated first? Is there a concrete use case, though? I don't have a good one in mind - though By the way, what if _pyio.FileIO inherited from io.FileIO instead of delegating all methods? I don't think that would work - but reasoning about MRO hurts my brain ;-) You'd have to declare the class like this: class FileIO(io.FileIO, IOBase): pass to get the io.File methods to resolve first. But that means that the method invocation chain would be broken by io.IOBase, which doesn't make super calls. Cheers, Brian -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5700 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5742] inspect.findsource() should look only for sources
New submission from Dmitry Vasiliev d...@hlabs.spb.ru: Currently help(zlib) gives the following traceback: Python 3.1a2+ (py3k:71538M, Apr 12 2009, 21:54:44) import zlib help(zlib) Traceback (most recent call last): File stdin, line 1, in module File Lib/site.py, line 429, in __call__ return pydoc.help(*args, **kwds) File Lib/pydoc.py, line 1709, in __call__ self.help(request) File Lib/pydoc.py, line 1755, in help else: doc(request, 'Help on %s:') File Lib/pydoc.py, line 1505, in doc pager(render_doc(thing, title, forceload)) File Lib/pydoc.py, line 1500, in render_doc return title % desc + '\n\n' + text.document(object, name) File Lib/pydoc.py, line 320, in document if inspect.ismodule(object): return self.docmodule(*args) File Lib/pydoc.py, line 1086, in docmodule contents.append(self.document(value, key, name)) File Lib/pydoc.py, line 321, in document if inspect.isclass(object): return self.docclass(*args) File Lib/pydoc.py, line 1131, in docclass doc = getdoc(object) File Lib/pydoc.py, line 81, in getdoc result = inspect.getdoc(object) or inspect.getcomments(object) File Lib/inspect.py, line 581, in getcomments lines, lnum = findsource(object) File Lib/inspect.py, line 524, in findsource lines = linecache.getlines(file, module.__dict__) File Lib/linecache.py, line 41, in getlines return updatecache(filename, module_globals) File Lib/linecache.py, line 127, in updatecache lines = fp.readlines() File Lib/codecs.py, line 300, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf8' codec can't decode bytes in position 41-42: invalid data After some investigation I've found that inspect.findsource() try to use getfile() if getsourcefile() fail to find the source file. I don't see why findsource() should return lines from a compiled file so I think it's a bug. The same bug also exists in Python 2.7 although it's not so critical. I've attached the patch which fixes the problem. -- components: Library (Lib) files: inspect.patch keywords: patch messages: 85916 nosy: hdima severity: normal status: open title: inspect.findsource() should look only for sources type: crash versions: Python 3.1 Added file: http://bugs.python.org/file13678/inspect.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5742 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5700] io.FileIO calls flush() after file closed
Brian Quinlan br...@sweetapp.com added the comment: Oops, I didn't finish my thought: No, doing this is trivial. But shouldn't it be up to the implementor of MyClass to decide whether MyMixin or io.FileIO methods are evaluated first? Is there a concrete use case, though? I don't have a good one in mind - though writing the unit test implementation required that the mixin class methods be called last. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5700 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5703] inside *currentmodule* some links is disabled
Georg Brandl ge...@python.org added the comment: You can write :class:`~email.mime.MIMENonMultipart`; this will link to the correct class but only display the thing after the last dot, in this case MIMENonMultipart. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5703 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5719] optparse: please provide a usage example in the module docstring
Georg Brandl ge...@python.org added the comment: Added in r71540. Thanks for the suggestion! -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5719 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5706] setuptools doesn't honor standard compiler variables
Garrett Cooper yaneg...@gmail.com added the comment: I did some quick inspection and it appears to be tied purely into setuptools, not distutils. distutils does support the environment variables properly. So I take this item and submit it to PEAK I suppose? Fun times . Thanks for the help. -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5706 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5743] multiprocessing.managers not accessible even though docs say so
New submission from Garrett Cooper yaneg...@gmail.com: I'm not sure why but my copy doesn't have a managers module. I'm really confused because multiprocessing.managers exists in Lib/multiprocessing/managers.py and it should have been installed with easy_install... Please see the attached testcase (it shows the details verifying that I don't have support). I ran it against all copies of python I have besides 3.x (nose doesn't support 3.x because setuptools isn't there yet for 3.x support). -bash-3.00$ python2.4 `which nosetests` ~/test_managers_support.py Python version: 2.4.5 (#1, Mar 28 2009, 14:54:51) [GCC 3.4.6 20060404 (Red Hat 3.4.6-9)]F == FAIL: test_managers_support.test_has_managers -- Traceback (most recent call last): File /ws/garrcoop-sjc/tools/lib/python2.4/site-packages/nose-0.10.4-py2.4.egg/nose/case.py, line 182, in runTest self.test(*self.arg) File /users/garrcoop/test_managers_support.py, line 9, in test_has_managers assert hasattr(multiprocessing, 'managers') AssertionError -- Ran 1 test in 0.050s FAILED (failures=1) -bash-3.00$ python2.5 `which nosetests` ~/test_managers_support.py /ws/garrcoop-sjc/tools/lib/python2.4/site-packages/multiprocessing-2.6.1.1-py2.4-linux-i686.egg/multiprocessing/__init__.py:86: RuntimeWarning: Python C API version mismatch for module _multiprocessing: This Python has API version 1013, module _multiprocessing has version 1012. import _multiprocessing Python version: 2.5.4 (r254:67916, Mar 28 2009, 15:01:19) [GCC 3.4.6 20060404 (Red Hat 3.4.6-9)]F == FAIL: test_managers_support.test_has_managers -- Traceback (most recent call last): File /ws/garrcoop-sjc/tools/lib/python2.4/site-packages/nose-0.10.4-py2.4.egg/nose/case.py, line 182, in runTest self.test(*self.arg) File /users/garrcoop/test_managers_support.py, line 9, in test_has_managers assert hasattr(multiprocessing, 'managers') AssertionError -- Ran 1 test in 0.159s FAILED (failures=1) -bash-3.00$ python2.6 `which nosetests` ~/test_managers_support.py F == FAIL: test_managers_support.test_has_managers -- Traceback (most recent call last): File /ws/garrcoop-sjc/tools/lib/python2.4/site-packages/nose-0.10.4-py2.4.egg/nose/case.py, line 182, in runTest self.test(*self.arg) File /users/garrcoop/test_managers_support.py, line 7, in test_has_managers assert hasattr(multiprocessing, 'managers') AssertionError -- Ran 1 test in 0.029s FAILED (failures=1) -- components: Extension Modules, Installation files: test_managers_support.py messages: 85921 nosy: jnoller, yaneurabeya severity: normal status: open title: multiprocessing.managers not accessible even though docs say so versions: Python 2.4, Python 2.5, Python 2.6, Python 3.0 Added file: http://bugs.python.org/file13679/test_managers_support.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5743 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5743] multiprocessing.managers not accessible even though docs say so
Garrett Cooper yaneg...@gmail.com added the comment: Sorry -- the info for my python2.6 was out of date. Here's the info (I had to set PYTHONPATH to to avoid a multiprocessing module conflict): bash-3.00$ PYTHONPATH=; python2.6 `which nosetests` ~/test_managers_support.py Python version: 2.6.1 (r261:67515, Mar 28 2009, 06:39:52) [GCC 3.4.6 20060404 (Red Hat 3.4.6-9)]F == FAIL: test_managers_support.test_has_managers -- Traceback (most recent call last): File /ws/garrcoop-sjc/tools/lib/python2.6/site-packages/nose-0.10.4-py2.6.egg/nose/case.py, line 182, in runTest self.test(*self.arg) File /users/garrcoop/test_managers_support.py, line 9, in test_has_managers assert hasattr(multiprocessing, 'managers') AssertionError -- Ran 1 test in 0.045s FAILED (failures=1) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5743 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5744] multiprocessing.managers.BaseManager.connect example typos
New submission from Garrett Cooper yaneg...@gmail.com: The example under multiprocessing.managers.BaseManager.connect has 2 typos: from multiprocessing.managers import BaseManager m = BaseManager(address='127.0.0.1', authkey='abc)) m.connect() Here's a corrected example: from multiprocessing.managers import BaseManager m = BaseManager(address='127.0.0.1', authkey='abc') m.connect() -- assignee: georg.brandl components: Documentation messages: 85924 nosy: georg.brandl, jnoller, yaneurabeya severity: normal status: open title: multiprocessing.managers.BaseManager.connect example typos versions: Python 2.6, Python 3.0 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5744 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5744] multiprocessing.managers.BaseManager.connect example typos
Benjamin Peterson benja...@python.org added the comment: Fixed in r71544. -- nosy: +benjamin.peterson resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5744 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5744] multiprocessing.managers.BaseManager.connect example typos
George Yoshida qui...@users.sourceforge.net added the comment: The example ... has *2* typos I guess the reporter wants to point out - extra parenthesis(fixed in r71544) - closing quote is missing for authkey argument -- nosy: +quiver status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5744 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5744] multiprocessing.managers.BaseManager.connect example typos
Benjamin Peterson benja...@python.org added the comment: Ah. My apologies. I thought the second typo was that it rendered incorrectly as your example shows. Fixed in r71546. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5744 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5736] Add the iterator protocol to dbm modules
Skip Montanaro s...@pobox.com added the comment: Akira Note that dbm and gdbm C API is a little different. gdbm_nextkey Akira requires key for its argument, dbm_nextkey don't. So I had to Akira use for gdbm an static variable that points to the current Akira position. I don't think this is going to fly. A static variable is not thread-safe. What's worse, even in a non-threaded environment you might want to iterate over the gdbm file simultaneously from two different places. -- nosy: +skip.montanaro ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5736 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5744] multiprocessing.managers.BaseManager.connect example typos
Changes by Benjamin Peterson benja...@python.org: -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5744 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5703] inside *currentmodule* some links is disabled
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: Thanks, I'll create the patch using this. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5703 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5703] inside *currentmodule* some links is disabled
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: I noticed :meth:`~email.message.Message.add_header` renders add_header but maybe Message.add_header is better? (Maybe sphinx tracker is suitable for now) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5703 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5736] Add the iterator protocol to dbm modules
Skip Montanaro s...@pobox.com added the comment: skip What's worse, even in a non-threaded environment you might want to skip iterate over the gdbm file simultaneously from two different skip places. Or iterate over two different gdbm files simultaneously. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5736 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5745] email document update (more links)
New submission from Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp: I added more links to email documantation. (I changed only :class: not :meth:) -- assignee: georg.brandl components: Documentation files: email_doc_link.patch keywords: patch messages: 85932 nosy: georg.brandl, ocean-city severity: normal status: open title: email document update (more links) versions: Python 2.7 Added file: http://bugs.python.org/file13680/email_doc_link.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5745 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5745] email document update (more links)
Changes by Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp: Added file: http://bugs.python.org/file13681/email_doc_link_aligned.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5745 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5730] setdefault speedup
Dan Schult dsch...@colgate.edu added the comment: On Apr 11, 2009, at 8:15 AM, Martin v. Löwis rep...@bugs.python.org@psf.upfronthosting.co.za @psf.upfronthosting.co.za wrote: Martin v. Löwis mar...@v.loewis.de added the comment: By the way, defaultdict is NOT like setdefault--it is like get(). Missing entries do no get set. Why do you say that? __missing__(...) __missing__(key) # Called by __getitem__ for missing key; pseudo-code: if self.default_factory is None: raise KeyError((key,)) self[key] = value = self.default_factory() return value In all cases of setdefault that I know of, replacing this with a defaultdict would be appropriate. The only case where it wouldn't work is if the default value depends on the key. The missing key reports the default object, but doesn't set that key or value object in the dict. So you cannot then call up that object and do something that depends on the key. So the default value may not depend on the key but still need to be different for each key due to later changes. For example, to represent a graph structure, it is helpful to use a dict-of-dicts. The first time a node is looked up you want to add it as a key in the graph dict with an empty nbr dict as the value. the nbr dict is keyed by neighbor to the edge weight/object. So the default object is always a fresh nbr dict... but what gets added to that nbr dict depends on which node it is. I can come up with examples for lists too... But as you pointed out before, using a list or dict in setdefault requires creating the object before the call anyway... I'm beginning to question whether setdefault should ever be used... Still comes back to--why have it there inefficiently. Besides I'm still interested in being able to do this sort of thing at least through the C-API... Raymond Hettinger rhettin...@users.sourceforge.net added the comment: from my perspective creating an internal SetItem adds another function handling the data structure just as setdefault would Incorrect comparison. Your in-lining manipulated the ep structure directly (not a good thing). In contrast, adding an alternative _PyDict_SetItemWithHash uses the insertdict() function, fully isolating itself of from the table implementation. The whole purpose of having insertdict() and lookdict() is to isolate the data structure internals from all externally visible functions. Good... I am understanding better what you mean by handling the data structure. I agree that lookdict, insertdict and resizedict should be the three that change the data structure. But the way those 3 are currently written, you can't change an entry without looking it up. insertdict_clean almost does it, but it assumes there aren't any dummy entries. The double call to a very simple user defined __hash__ adds .07 to call that takes on .05 with the double call to builtin object hash. So, we could save half of the the .07 just by elimating the double call to __hash__. With more complex hash functions the overall speedup is huge (essentially cutting the total work almost in half). This is a good example because it shows how the hash can matter. I think there are similar examples where the lookup is most of the time of dict access. I don't know enough about what causes collisions and how dicts are optimized to quickly come up with such an example. But such an example must exist or Tim Peters wouldn't have spent so much effort optimizing lookup besides his comments at the top of lookup suggest that we do exactly what I am suggesting to do. Get the entry from lookup and then the caller can (if it wishes) add the key, value pair to the returned PyDictEntry*. Presently there is no way to do this with C-API except to write my own data structure manipulation. Wouldn't it be better to encapsulate this in the C-API in a standard way instead of having everybody writing their own C-extension doing setdefault the right way? (ok..ok.. everybody here refers to probably one person (me)... but others have thought of it. I've even seen the double lookup as a justification for never using setdefault) I'll look for an example that has lots of collisions. Maybe that would help justify a lookup-less insertdict. Dan -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5730 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5744] multiprocessing.managers.BaseManager.connect example typos
Garrett Cooper yaneg...@gmail.com added the comment: Thanks for noting that George Y. and thanks for fixing the documentation on SVN Benjamin :). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5744 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3440] Starting any program as a subprocess fails when subprocess.Popen has env argument
Lenard Lindstrom le...@telus.net added the comment: notepad.exe forms a side-by-side assembly with COMCTL32.DLL. So SystemRoot must be included in the environment. The following example works with Python 2.5.2 on Windows XP. === import struct, subprocess import os command = 'C:\\WINDOWS\\NOTEPAD.EXE' env = {'FOO': 'bar', 'SystemRoot': os.environ['SystemRoot']} p = subprocess.Popen(command, env=env) p.wait() err = struct.unpack('I', struct.pack('i', p.returncode))[0] print '%x (%d)'%(err, err) === I would suggest Popen adds SystemRoot to env if it is not present. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3440 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5746] socketserver problem upon disconnection (undefined member)
New submission from Eric Blond ebl...@tiscali.co.uk: Here's the traceback I got: === s.serve_forever() Exception happened during processing of request from ('127.0.0.1', 54611) Traceback (most recent call last): File C:\Python30\lib\socketserver.py, line 281, in _handle_request_noblock self.process_request(request, client_address) File C:\Python30\lib\socketserver.py, line 307, in process_request self.finish_request(request, client_address) File C:\Python30\lib\socketserver.py, line 320, in finish_request self.RequestHandlerClass(request, client_address, self) File C:\Python30\lib\socketserver.py, line 615, in __init__ self.finish() File C:\Python30\lib\socketserver.py, line 655, in finish if not self.wfile.closed: AttributeError: 'RequestHandler' object has no attribute 'wfile' === 's' is an instance of socketserver.TCPServer and the handler passed is an instance of socketserver.StreamRequestHandler. I believe this must be a simple typo, so I didn't feel that more details is needed at that point. Let me know if you have any question. -- components: Library (Lib) messages: 85936 nosy: eblond severity: normal status: open title: socketserver problem upon disconnection (undefined member) versions: Python 3.0 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5746 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com