From report at bugs.python.org Thu Aug 1 00:21:51 2013 From: report at bugs.python.org (Catherine Devlin) Date: Wed, 31 Jul 2013 22:21:51 +0000 Subject: [issue1666318] shutil.copytree doesn't give control over directory permissions Message-ID: <1375309311.97.0.698221223399.issue1666318@psf.upfronthosting.co.za> Catherine Devlin added the comment: Thanks, Antoine - I've signed and submitted the Contributor's Agreement. ---------- Added file: http://bugs.python.org/file31104/Python Contributor Agreement Form - signed.pdf _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 00:39:26 2013 From: report at bugs.python.org (Richard Oudkerk) Date: Wed, 31 Jul 2013 22:39:26 +0000 Subject: [issue18214] Stop purging modules which are garbage collected before shutdown In-Reply-To: <1371221979.53.0.00385452158182.issue18214@psf.upfronthosting.co.za> Message-ID: <1375310366.88.0.440570013978.issue18214@psf.upfronthosting.co.za> Richard Oudkerk added the comment: I played a bit with the patch and -v -Xshowrefcount. The number of references and blocks left at exit varies (and is higher than for unpatched python). It appears that a few (1-3) module dicts are not being purged because they have been "orphaned". (i.e. the module object was garbaged collected before we check the weakref, but the module dict survived.) Presumably it is the hash randomization causing the randomness. Maybe 8 out of 50+ module dicts actually die a natural death by being garbage collected before they are purged. Try ./python -v -Xshowrefcount check_purging.py ---------- Added file: http://bugs.python.org/file31105/check_purging.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 00:48:21 2013 From: report at bugs.python.org (Robin Schoonover) Date: Wed, 31 Jul 2013 22:48:21 +0000 Subject: [issue18610] wsgiref.validator expects wsgi.input read to give exactly one arg Message-ID: <1375310901.82.0.276465395742.issue18610@psf.upfronthosting.co.za> New submission from Robin Schoonover: wsgiref.validator requires wsgi.input's read to always give EXACTLY one argument. This is incorrect. It's own documentation says: * That wsgi.input is used properly: - .read() is called with zero or one argument PEP3333 says: A server should allow read() to be called without an argument, and return the remainder of the client's input stream. ---------- components: Library (Lib) files: wsgiref.patch keywords: patch messages: 194027 nosy: Robin.Schoonover priority: normal severity: normal status: open title: wsgiref.validator expects wsgi.input read to give exactly one arg type: behavior versions: Python 3.3 Added file: http://bugs.python.org/file31106/wsgiref.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 00:50:39 2013 From: report at bugs.python.org (Robin Schoonover) Date: Wed, 31 Jul 2013 22:50:39 +0000 Subject: [issue18610] wsgiref.validate expects wsgi.input read to give exactly one arg In-Reply-To: <1375310901.82.0.276465395742.issue18610@psf.upfronthosting.co.za> Message-ID: <1375311039.81.0.202586251052.issue18610@psf.upfronthosting.co.za> Changes by Robin Schoonover : ---------- title: wsgiref.validator expects wsgi.input read to give exactly one arg -> wsgiref.validate expects wsgi.input read to give exactly one arg _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 00:51:26 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Wed, 31 Jul 2013 22:51:26 +0000 Subject: [issue11571] Turtle window pops under the terminal on OSX In-Reply-To: <1300287451.35.0.164099198094.issue11571@psf.upfronthosting.co.za> Message-ID: <1375311086.03.0.950312882762.issue11571@psf.upfronthosting.co.za> Changes by Alexander Belopolsky : ---------- resolution: -> wont fix status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 00:57:14 2013 From: report at bugs.python.org (Arfrever Frehtes Taifersar Arahesis) Date: Wed, 31 Jul 2013 22:57:14 +0000 Subject: [issue18603] PyOS_mystricmp unused and no longer available In-Reply-To: <1375228725.23.0.641374823001.issue18603@psf.upfronthosting.co.za> Message-ID: <1375311434.72.0.613812525559.issue18603@psf.upfronthosting.co.za> Changes by Arfrever Frehtes Taifersar Arahesis : ---------- nosy: +Arfrever _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 02:11:39 2013 From: report at bugs.python.org (Christian Heimes) Date: Thu, 01 Aug 2013 00:11:39 +0000 Subject: [issue1666318] shutil.copytree doesn't give control over directory permissions Message-ID: <1375315899.39.0.541384154388.issue1666318@psf.upfronthosting.co.za> Christian Heimes added the comment: Hi Catherine, the contributor agreement must go through proper channels. The bug tracker is not the right place to post your agreement. Please follow the instructions at http://www.python.org/psf/contrib/ . You can submit the agreement electronically, too. ---------- nosy: +christian.heimes _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 02:11:48 2013 From: report at bugs.python.org (Christian Heimes) Date: Thu, 01 Aug 2013 00:11:48 +0000 Subject: [issue1666318] shutil.copytree doesn't give control over directory permissions Message-ID: <1375315908.43.0.405463028578.issue1666318@psf.upfronthosting.co.za> Changes by Christian Heimes : Removed file: http://bugs.python.org/file31104/Python Contributor Agreement Form - signed.pdf _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 02:48:43 2013 From: report at bugs.python.org (Roundup Robot) Date: Thu, 01 Aug 2013 00:48:43 +0000 Subject: [issue17616] wave.Wave_read and wave.Wave_write can be context managers In-Reply-To: <1364894166.78.0.454807000252.issue17616@psf.upfronthosting.co.za> Message-ID: <3c5CYP4PNPz7Lk1@mail.python.org> Roundup Robot added the comment: New changeset 4f3b6eff2ede by R David Murray in branch 'default': #17616: Improve context manager tests, fix bugs in close method and mode docs. http://hg.python.org/cpython/rev/4f3b6eff2ede ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 03:11:52 2013 From: report at bugs.python.org (Bill Gale) Date: Thu, 01 Aug 2013 01:11:52 +0000 Subject: [issue7511] msvc9compiler.py: ValueError when trying to compile with VC Express In-Reply-To: <1260858478.84.0.495655867168.issue7511@psf.upfronthosting.co.za> Message-ID: <1375319511.99.0.907062436998.issue7511@psf.upfronthosting.co.za> Bill Gale added the comment: so i hit the same exception, here is how i solved it. environment: windows 7 enterprise 64 bit python 2.7.5 64 bit visual studio 2008 32 bit issue: pip installs failed with the above exception. solution: there are two parts. 1. install 64 bit components to vs2008 2. modify the PATH to point to 64 bit vs2008 bin folder to confirm is this solution will help you: check if there is an amd64 under your vs2008 bin folder: C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin if yes, this solution will not help you. if missing follow the steps below. step 1. control panel select Microsoft Visual Studio 2008 Professional -ENU window Visual Studio 2008 Maintenance Mode is opened click through to and select Add or Remove Features Under Language Tools->VC++ "X64 Compilers and Tools" should be unchecked. if it is checked, skip to step 2. check "X64 Compilers and Tools", Update. you may have to provide the VS2008 installation CD. confirm that update creates bin\amd64 subfolder. step 2. add 64 bit subfolder to your path. VS2008_HOME=C:\Program Files (x86)\Microsoft Visual Studio 9.0 PATH=%PATH%;%VS2008_HOME%\VC\bin;%VS2008_HOME%\VC\bin\amd64; open new command window to receive new PATH changes. pip installations should no die with the ValueError. ---------- nosy: +bgale _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 06:35:31 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Thu, 01 Aug 2013 04:35:31 +0000 Subject: [issue1666318] shutil.copytree doesn't give control over directory permissions Message-ID: <1375331731.86.0.121049235479.issue1666318@psf.upfronthosting.co.za> Vajrasky Kok added the comment: Hi Catherine, I saw your patch. It looks good, except you are trying to copy the directory onto its subdirectory. src_dir = tempfile.mkdtemp() dst_dir = os.path.join(tempfile.mkdtemp(), 'destination') I prefer it if you copy it to somewhere else. This would be better: tmp_dir = self.mkdtemp() src = os.path.join(tmp_dir, 'foo') dst = os.path.join(tmp_dir, 'bar') ---------- nosy: +vajrasky _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 07:58:41 2013 From: report at bugs.python.org (Bohuslav "Slavek" Kabrda) Date: Thu, 01 Aug 2013 05:58:41 +0000 Subject: [issue17998] internal error in regular expression engine In-Reply-To: <1368803354.84.0.768428094886.issue17998@psf.upfronthosting.co.za> Message-ID: <1375336721.45.0.728085399172.issue17998@psf.upfronthosting.co.za> Changes by Bohuslav "Slavek" Kabrda : ---------- nosy: +bkabrda _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 09:14:26 2013 From: report at bugs.python.org (Michael Foord) Date: Thu, 01 Aug 2013 07:14:26 +0000 Subject: [issue16662] load_tests not invoked in package/__init__.py In-Reply-To: <1355217291.85.0.41912767842.issue16662@psf.upfronthosting.co.za> Message-ID: <1375341266.01.0.367607810958.issue16662@psf.upfronthosting.co.za> Michael Foord added the comment: I'm happy with the check being removed. The old behaviour was documented I believe - so there'd need to be documentation changes to go with it. As the old behaviour is so "un-useful" I don't think there are backward compatibility issues with changing it. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 09:44:55 2013 From: report at bugs.python.org (=?utf-8?q?C=C3=A9dric_Krier?=) Date: Thu, 01 Aug 2013 07:44:55 +0000 Subject: [issue17998] internal error in regular expression engine In-Reply-To: <1368803354.84.0.768428094886.issue17998@psf.upfronthosting.co.za> Message-ID: <1375343095.04.0.714809905119.issue17998@psf.upfronthosting.co.za> Changes by C?dric Krier : ---------- nosy: +ced _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 10:21:10 2013 From: report at bugs.python.org (Larry Hastings) Date: Thu, 01 Aug 2013 08:21:10 +0000 Subject: [issue16245] Update html.entities.html5 dictionary and parseentities.py In-Reply-To: <1350380511.49.0.860998010837.issue16245@psf.upfronthosting.co.za> Message-ID: <1375345270.34.0.233852492299.issue16245@psf.upfronthosting.co.za> Larry Hastings added the comment: I'm downgrading this to "deferred blocker". We'll make sure it happens before Python 3.4.0, but there's no need to hold up Python 3.4a1 for this. ---------- priority: release blocker -> deferred blocker _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 10:22:13 2013 From: report at bugs.python.org (Larry Hastings) Date: Thu, 01 Aug 2013 08:22:13 +0000 Subject: [issue18257] Two copies of python-config In-Reply-To: <1371567872.42.0.116049773773.issue18257@psf.upfronthosting.co.za> Message-ID: <1375345333.6.0.389139375628.issue18257@psf.upfronthosting.co.za> Larry Hastings added the comment: Okay, downgrading to "deferred blocker". ---------- priority: release blocker -> deferred blocker _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 10:23:29 2013 From: report at bugs.python.org (Larry Hastings) Date: Thu, 01 Aug 2013 08:23:29 +0000 Subject: [issue5302] Allow package_data specs/globs to match directories In-Reply-To: <1234909934.56.0.127417684931.issue5302@psf.upfronthosting.co.za> Message-ID: <1375345409.54.0.198620772308.issue5302@psf.upfronthosting.co.za> Larry Hastings added the comment: And this will hold up Python 3.4a1, as I can't close #13463 until this is closed first. So I'm closing this as wontfix. ---------- nosy: +larry resolution: -> wont fix status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 10:23:59 2013 From: report at bugs.python.org (Larry Hastings) Date: Thu, 01 Aug 2013 08:23:59 +0000 Subject: [issue13463] Fix parsing of package_data In-Reply-To: <1322068433.36.0.783240091616.issue13463@psf.upfronthosting.co.za> Message-ID: <1375345439.28.0.0647222076793.issue13463@psf.upfronthosting.co.za> Larry Hastings added the comment: This was held up by #5302, so I just closed that one too as the same rule applies. ---------- status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 10:25:03 2013 From: report at bugs.python.org (Larry Hastings) Date: Thu, 01 Aug 2013 08:25:03 +0000 Subject: [issue17998] internal error in regular expression engine In-Reply-To: <1368803354.84.0.768428094886.issue17998@psf.upfronthosting.co.za> Message-ID: <1375345503.26.0.999332787957.issue17998@psf.upfronthosting.co.za> Larry Hastings added the comment: Can I downgrade this to "deferred blocker"? That means we still need to deal with it before the release, but we don't have to hold up Python 3.4a1 for it. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 11:34:14 2013 From: report at bugs.python.org (Ronald Oussoren) Date: Thu, 01 Aug 2013 09:34:14 +0000 Subject: [issue18181] PEP447: Add type.__locallookup__ In-Reply-To: <1370870153.93.0.646087371852.issue18181@psf.upfronthosting.co.za> Message-ID: <1375349654.28.0.341959386734.issue18181@psf.upfronthosting.co.za> Ronald Oussoren added the comment: Updated the patch for PEP 442. ---------- Added file: http://bugs.python.org/file31107/issue-18181-full-v4.txt _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 11:37:05 2013 From: report at bugs.python.org (Ronald Oussoren) Date: Thu, 01 Aug 2013 09:37:05 +0000 Subject: [issue5262] PythonLauncher considered harmfull In-Reply-To: <1234638505.38.0.029039550018.issue5262@psf.upfronthosting.co.za> Message-ID: <1375349825.54.0.897654219883.issue5262@psf.upfronthosting.co.za> Ronald Oussoren added the comment: The attached patch removes the code that checks if "Python Launcher" is the default application for opening python files. ---------- Added file: http://bugs.python.org/file31108/issue-5262.txt _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 11:49:15 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 09:49:15 +0000 Subject: [issue18214] Stop purging modules which are garbage collected before shutdown In-Reply-To: <1371221979.53.0.00385452158182.issue18214@psf.upfronthosting.co.za> Message-ID: <1375350555.58.0.466500236393.issue18214@psf.upfronthosting.co.za> Antoine Pitrou added the comment: > It appears that a few (1-3) module dicts are not being purged because they > have been "orphaned". (i.e. the module object was garbaged collected before > we check the weakref, but the module dict survived.) Module globals can be kept alive by any function defined in that module. So if that function is registered eternally in a C static variable, the globals dict will never get collected. > ./python -v -Xshowrefcount check_purging.py I always get either: # remaining {'encodings', '__main__'} [...] [24834 refs, 7249 blocks] or # remaining {'__main__', 'encodings'} [...] [24834 refs, 7249 blocks] ... which seems to hint that it is quite stable actually. The encodings globals are kept alive because of the codecs registration, I believe. As for the __main__ dict, perhaps we're missing a decref somewhere. > Maybe 8 out of 50+ module dicts actually die a natural death by being > garbage collected before they are purged. I get different numbers from you. If I run "./python -v -c pass", most modules in the "wiping" phase are C extension modules, which is expected. Pretty much every pure Python module ends up garbage collected before that. By the way, please also try issue18608 which will bring an other improvement. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 11:50:44 2013 From: report at bugs.python.org (Ronald Oussoren) Date: Thu, 01 Aug 2013 09:50:44 +0000 Subject: [issue18611] Mac: Some Python Launcher issues Message-ID: <1375350644.84.0.910420929307.issue18611@psf.upfronthosting.co.za> New submission from Ronald Oussoren: There are some issues with the Python Launcher application: 1) There is a useless 'Help' menu, the application does not include help (removal is trivial and doesn't affect functionality) 2) The list of interpreters does not include the framework locations, only /usr/local, /usr and /sw (Fink). IMHO the factory default should only include the framework and system pythons. 3) Python Launcher should probably sniff the script for a '#!', if only to detect if the script is python 2 or 3. This may need to be an option, an the algoritm needs to be specified. Probably something like: - No #!: use app setting - #!/usr/bin/env ...: use '...' to determine python version, use app setting to find that. Rationale: /usr/bin/env uses $PATH to find a binary, the value of $PATH for GUI apps cannot easily be changed by users (if at all, there used to be an environment.plist file but I haven't checked if thats still used by the system). Therefore it is better to use an application setting for this. - #!/path/to/python: use that interpreter if it exists (not sure yet what should happen if that interpreter does not exist) This has several advantages over the current behavior: - Can use a single Python Launcher for python2 and python3 scripts - Works with virtualenv/pyvenv environments (assuming that the right path is used in the #! line) See also the pep397 specification for the "py" launcher on windows, but I don't propose to add such a command-line tool to Mac installations, the normal Unix conventions work just fine for command-line use. See als #5262 ---------- assignee: ronaldoussoren components: Macintosh messages: 194041 nosy: ned.deily, ronaldoussoren priority: normal severity: normal stage: needs patch status: open title: Mac: Some Python Launcher issues type: behavior versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 11:55:59 2013 From: report at bugs.python.org (Christian Heimes) Date: Thu, 01 Aug 2013 09:55:59 +0000 Subject: [issue18608] Avoid keeping a strong reference to locale in the _io module In-Reply-To: <1375305631.67.0.684843179592.issue18608@psf.upfronthosting.co.za> Message-ID: <1375350959.61.0.321816776394.issue18608@psf.upfronthosting.co.za> Changes by Christian Heimes : ---------- nosy: +christian.heimes _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 11:56:34 2013 From: report at bugs.python.org (Christian Heimes) Date: Thu, 01 Aug 2013 09:56:34 +0000 Subject: [issue18214] Stop purging modules which are garbage collected before shutdown In-Reply-To: <1371221979.53.0.00385452158182.issue18214@psf.upfronthosting.co.za> Message-ID: <1375350994.33.0.514039468098.issue18214@psf.upfronthosting.co.za> Changes by Christian Heimes : ---------- nosy: +christian.heimes _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 11:59:25 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 09:59:25 +0000 Subject: [issue18214] Stop purging modules which are garbage collected before shutdown In-Reply-To: <1371221979.53.0.00385452158182.issue18214@psf.upfronthosting.co.za> Message-ID: <1375351165.31.0.90572956917.issue18214@psf.upfronthosting.co.za> Antoine Pitrou added the comment: > As for the __main__ dict, perhaps we're missing a decref somewhere. Actually, it's not surprising. Blob's methods hold a reference to the __main__ globals, and there's still a Blob object alive in encodings. If you replace the end of your script with the following: for name, mod in sys.modules.items(): if name != 'encodings': mod.__dict__["__blob__"] = Blob(name) del name, mod, Blob then at the end of the shutdown phase, remaining is empty. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 12:27:14 2013 From: report at bugs.python.org (Richard Oudkerk) Date: Thu, 01 Aug 2013 10:27:14 +0000 Subject: [issue18214] Stop purging modules which are garbage collected before shutdown In-Reply-To: <1375351165.31.0.90572956917.issue18214@psf.upfronthosting.co.za> Message-ID: <51FA37F9.5020405@gmail.com> Richard Oudkerk added the comment: On 01/08/2013 10:59am, Antoine Pitrou wrote: > If you replace the end of your script with the following: > > for name, mod in sys.modules.items(): > if name != 'encodings': > mod.__dict__["__blob__"] = Blob(name) > del name, mod, Blob > > > then at the end of the shutdown phase, remaining is empty. On Windows, even with this change, I get for example: # remaining {'encodings.mbcs', '__main__', 'encodings.cp1252'} ... [22081 refs, 6742 blocks] or # remaining {'__main__', 'encodings'} ... [23538 refs, 7136 blocks] ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 12:40:39 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 10:40:39 +0000 Subject: [issue18214] Stop purging modules which are garbage collected before shutdown In-Reply-To: <1371221979.53.0.00385452158182.issue18214@psf.upfronthosting.co.za> Message-ID: <1375353639.23.0.690904372683.issue18214@psf.upfronthosting.co.za> Antoine Pitrou added the comment: You might want to open a prompt and look at gc.get_referrers() for encodings.mbcs.__dict__ (or another of those modules). ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 13:08:35 2013 From: report at bugs.python.org (Richard Oudkerk) Date: Thu, 01 Aug 2013 11:08:35 +0000 Subject: [issue18214] Stop purging modules which are garbage collected before shutdown In-Reply-To: <1371221979.53.0.00385452158182.issue18214@psf.upfronthosting.co.za> Message-ID: <1375355315.8.0.935721723114.issue18214@psf.upfronthosting.co.za> Richard Oudkerk added the comment: > You might want to open a prompt and look at gc.get_referrers() for > encodings.mbcs.__dict__ (or another of those modules). >>> gc.get_referrers(sys.modules['encodings.mbcs'].__dict__) [, , , ] >>> gc.get_referrers(sys.modules['encodings.cp1252'].__dict__) [, , , , , ] >>> gc.get_referrers(sys.modules['__main__'].__dict__) [, , , at 0x02AD3DB8>, , )>] ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 13:09:35 2013 From: report at bugs.python.org (Tim Golden) Date: Thu, 01 Aug 2013 11:09:35 +0000 Subject: [issue18306] os.stat gives exception for Windows junctions in v3.3 In-Reply-To: <1372236300.43.0.559187613539.issue18306@psf.upfronthosting.co.za> Message-ID: <1375355375.68.0.308421150629.issue18306@psf.upfronthosting.co.za> Tim Golden added the comment: I propose to close this one: using Python 3.3 on Win7 I can successfully stat NTFS Junctions. Is there any remaining issue? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 13:17:24 2013 From: report at bugs.python.org (Richard Oudkerk) Date: Thu, 01 Aug 2013 11:17:24 +0000 Subject: [issue18214] Stop purging modules which are garbage collected before shutdown In-Reply-To: <1371221979.53.0.00385452158182.issue18214@psf.upfronthosting.co.za> Message-ID: <1375355844.87.0.23023177643.issue18214@psf.upfronthosting.co.za> Richard Oudkerk added the comment: > I get different numbers from you. If I run "./python -v -c pass", most > modules in the "wiping" phase are C extension modules, which is expected. > Pretty much every pure Python module ends up garbage collected before > that. The *module* gets gc'ed, sure. But you can't tell from "./python -v -c pass" when the *module dict* get gc'ed. Using "./python -v check_purging.py", before the purging stage (# cleanup [3]) I only get # purge/gc operator 54 # purge/gc io 53 # purge/gc keyword 52 # purge/gc types 51 # purge/gc sysconfig 50 That leaves lots of pure python module dicts to be purged later on. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 13:23:32 2013 From: report at bugs.python.org (uglemat) Date: Thu, 01 Aug 2013 11:23:32 +0000 Subject: [issue18612] More elaborate documentation on how list comprehensions and generator expressions relate to each other Message-ID: <1375356212.93.0.797789110077.issue18612@psf.upfronthosting.co.za> New submission from uglemat: Today there are list comprehensions, set comprehensions, dict comprehensions and then... there are generator expressions, which apparently was called 'generator comprehensions' in the original PEP, don't know why that was changed. Some questions arises: * Are generator expressions a type of list comprehension, or are generator expressions to be considered their own thing. * Does 'list comprehension' mean a type of comprehension that happens to return a list, or is it to be considered more of a general concept. I usually talk about 'list comprehension' as a type of comprehension, and 'generator expression' as another type of comprehension, and after investigating whether or not that is correct I couldn't find an answer. On the wikipedia article on list comprension (http://en.wikipedia.org/wiki/List_comprehension#Python) they list generator expressions as well, indicating that it's a type of list comprehension. I think there's a lot of confusion to be had here, and that the documentation should clarify what exactly is meant by 'list comprehensions', regardless of what happens to be the case. I haven't really a bug report before, so forgive me if I'm doing something wrong. :) ---------- assignee: docs at python components: Documentation messages: 194048 nosy: docs at python, uglemat priority: normal severity: normal status: open title: More elaborate documentation on how list comprehensions and generator expressions relate to each other versions: Python 3.5 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 13:45:54 2013 From: report at bugs.python.org (Roundup Robot) Date: Thu, 01 Aug 2013 11:45:54 +0000 Subject: [issue9035] os.path.ismount on windows doesn't support windows mount points In-Reply-To: <1277023751.91.0.438330382261.issue9035@psf.upfronthosting.co.za> Message-ID: <3c5V7j6P8wz7LjZ@mail.python.org> Roundup Robot added the comment: New changeset f283589cb71e by Tim Golden in branch 'default': Issue #9035: os.path.ismount now recognises volumes mounted below http://hg.python.org/cpython/rev/f283589cb71e ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 14:01:51 2013 From: report at bugs.python.org (Laurent Fournier) Date: Thu, 01 Aug 2013 12:01:51 +0000 Subject: [issue18613] wrong float minus op result Message-ID: <1375358511.45.0.0761593009905.issue18613@psf.upfronthosting.co.za> New submission from Laurent Fournier: Python 3.3.1 (with GCC 4.7.3) on Linux print (.3-.1) 0.199999999999999998 ---------- messages: 194050 nosy: Laurent.Fournier priority: normal severity: normal status: open title: wrong float minus op result type: behavior versions: Python 3.3 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 14:05:27 2013 From: report at bugs.python.org (=?utf-8?q?Martin_v=2E_L=C3=B6wis?=) Date: Thu, 01 Aug 2013 12:05:27 +0000 Subject: [issue18517] "xxlimited" extension declared incorrectly in setup.py In-Reply-To: <1374393760.41.0.977042124577.issue18517@psf.upfronthosting.co.za> Message-ID: <1375358727.89.0.932931433446.issue18517@psf.upfronthosting.co.za> Martin v. L?wis added the comment: I would be fine with it being build only in a debug build. The rationale for the module is that it should test whether the header files actually compile under the limited API (or whether e.g. some functions are exposed that rely on unexposed structures). So the main test is really whether it compiles. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 14:14:51 2013 From: report at bugs.python.org (=?utf-8?q?Martin_v=2E_L=C3=B6wis?=) Date: Thu, 01 Aug 2013 12:14:51 +0000 Subject: [issue18521] [cppcheck] Full report In-Reply-To: <1374408848.64.0.369654911435.issue18521@psf.upfronthosting.co.za> Message-ID: <1375359291.78.0.264591619982.issue18521@psf.upfronthosting.co.za> Martin v. L?wis added the comment: Julien: I propose to resolve this issue in the same way as we have done previously with analysis tools (with some unfortunate exceptions). Somebody motivated enough (hopefully you) agrees to initially study the tool output, and ideally also then agrees to run the tool on a regular basis (but this is really not mandatory - the help with the initial run is already appreciated). You would then filter out the reports, and see which of them are useful. If you can, have the tool silence the bogus reports (e.g. with a configuration file). For the issues that you consider valid, please file individual bug reports (possibly combining related reports, e.g. by module or by error kind, but only if they can all be reasonably fixed in a single commit). The key concern of the developers here is probably this: a) there is no doubt that getting issues detected and fixed would be a helpful contribution, but b) the amount of false positives makes it unattractive to actually run the tool yourself. If you do not want to volunteer, this is fine as well. Just don't feel sad if the issue gets closed with no action. ---------- nosy: +loewis _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 14:16:31 2013 From: report at bugs.python.org (Laurent Fournier) Date: Thu, 01 Aug 2013 12:16:31 +0000 Subject: [issue18613] wrong float plus/minus op result In-Reply-To: <1375358511.45.0.0761593009905.issue18613@psf.upfronthosting.co.za> Message-ID: <1375359391.0.0.800896436484.issue18613@psf.upfronthosting.co.za> Laurent Fournier added the comment: also with addition ! print (.05+.01) 0.0600000000000000005 ---------- title: wrong float minus op result -> wrong float plus/minus op result _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 14:19:38 2013 From: report at bugs.python.org (Nick Coghlan) Date: Thu, 01 Aug 2013 12:19:38 +0000 Subject: [issue18472] Update PEP 8 to encourage modern conventions In-Reply-To: <1373973528.84.0.159091610788.issue18472@psf.upfronthosting.co.za> Message-ID: <1375359578.69.0.338177002419.issue18472@psf.upfronthosting.co.za> Nick Coghlan added the comment: Changes in version 5: - added a new reference pointing back to this tracker issue. I figure that's a good precedent to set for future updates. - I liked Barry's point about "Don't break backwards compatility" enough that I moved it into its own paragraph ahead of the bulleted list and changed the heading to "Some other good..." - changed a few more cases of "rule" to "guideline" - tabs vs spaces section now strongly prefers spaces, saying tabs should be used only for legacy compatibility reasons - changed the line length recommendation to allow up to 99 characters when it improves readability (I kept 79 as the default recommendation, and 72 for reflowing long blocks of text) - rewrapped my additions to the PEP at 72 chars ;) - encodings section no longer mentions Latin-1, referring only to UTF-8, ASCII and non-ASCII. - class based exception note changed to a recommendation to inherit from Exception (this ended up leading quite well into the comment about inheritance heirarchy design) - we already had an admonition to avoid bare except clauses (as well as "except BaseException:") - dropped the "highly" from the annotation decorator recommendation - added a note that the public/internal API guideline still applies when using a wildcard import to republish APIs, as well as noting you should only use them when you don't know the list of republished names in advance I *didn't* make any changes in relation to Barry's comment about having the commentary intermixed with the guidelines. I quite like the notion of stripping PEP 8 down to just the essentials and having PEP 108 as "The annotated PEP 8", but that's a bigger project than I'm prepared to tackle (heck, even the *current* patch turned out to be a far more substantial update than I expected!). I'll commit this version - feel free to tweak further in the PEP repo if you spot any mistakes :) I deliberately left the following point out since Guido said "out of scope" above (I wrote it before noticing that): - Use an iterator or a "loop-and-a-half" construct rather than repeating loop setup code in the body of the loop. Yes:: def itervalues(x): yield x.getvalue() for value in itervalues(obj): process(value) Yes:: while True: value = obj.getvalue() if not value: break process(value) No:: value = obj.getvalue() while value: process(value) value = obj.getvalue() ---------- Added file: http://bugs.python.org/file31109/issue18472_pep_8_update5.diff _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 14:23:41 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 12:23:41 +0000 Subject: [issue18214] Stop purging modules which are garbage collected before shutdown In-Reply-To: <1371221979.53.0.00385452158182.issue18214@psf.upfronthosting.co.za> Message-ID: <1375359821.13.0.0215219004833.issue18214@psf.upfronthosting.co.za> Antoine Pitrou added the comment: Here (Linux) I get the following: # purge/gc os.path 12 # purge/gc operator 50 # purge/gc io 49 # purge/gc _sysconfigdata 48 # purge/gc sysconfig 47 # purge/gc keyword 46 # purge/gc site 45 # purge/gc types 44 Also, do note that purge/gc after wiping can still be a regular gc pass unless the module has been wiped. The gc could be triggered by another module being wiped. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 14:24:47 2013 From: report at bugs.python.org (Nick Coghlan) Date: Thu, 01 Aug 2013 12:24:47 +0000 Subject: [issue18472] Update PEP 8 to encourage modern conventions In-Reply-To: <1373973528.84.0.159091610788.issue18472@psf.upfronthosting.co.za> Message-ID: <1375359887.08.0.408210107693.issue18472@psf.upfronthosting.co.za> Nick Coghlan added the comment: For the record, the thread where Thomas Wouters provided the feedback that led to the current wording regarding imports: http://mail.python.org/pipermail/python-dev/2013-July/127373.html ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 14:37:22 2013 From: report at bugs.python.org (R. David Murray) Date: Thu, 01 Aug 2013 12:37:22 +0000 Subject: [issue18612] More elaborate documentation on how list comprehensions and generator expressions relate to each other In-Reply-To: <1375356212.93.0.797789110077.issue18612@psf.upfronthosting.co.za> Message-ID: <1375360642.97.0.509501336354.issue18612@psf.upfronthosting.co.za> R. David Murray added the comment: Well, you haven't done anything wrong, but I'm not sure what we can do in response to the report. What how will the answer to the question serve you? What will you know after getting the answer that you didn't know before getting the answer? I'm trying here to understand what it is that is missing from your mental model of Python that needs to be filled in, because the syntax and behavior of these constructs is documented, and it has never occurred to me to wonder whether or not a generator expression "is" a comprehension or not. I'm making things up here, but I suspect we call generator expressions that because while they share the base syntax and much of the same semantics as the things we call comprehensions, (a) they produce an iterable (a generator object) instead instead of a fully realized object and (b) you can specify a generator expression without explicit surrounding punctuation (eg: "myfunc(x for x in range(7))"). That is, the 'comprehensions' are conceptually a notation for "specifying" a collection object using a compact notation, while a generator expression is a way of "creating" a generator-iterable *function* that must then be iterated to produce the collection object implicitly specified by the expression. I'm not sure I'm being clear, because the distinction is subtle and perhaps not meaningful...the difference in naming might just be an historical accident :) And, because it is not entirely clear, I'm not sure it is a good idea to try to document it. Again, what enlightenment would derive from a clear explanation? ---------- nosy: +r.david.murray versions: +Python 2.7, Python 3.3, Python 3.4 -Python 3.5 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 14:42:34 2013 From: report at bugs.python.org (Eli Bendersky) Date: Thu, 01 Aug 2013 12:42:34 +0000 Subject: [issue12645] test.support. import_fresh_module - incorrect doc In-Reply-To: <1311789815.76.0.639942891335.issue12645@psf.upfronthosting.co.za> Message-ID: <1375360954.84.0.771246589439.issue12645@psf.upfronthosting.co.za> Eli Bendersky added the comment: Ben, would you like to provide an updated patch? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 14:44:52 2013 From: report at bugs.python.org (Eli Bendersky) Date: Thu, 01 Aug 2013 12:44:52 +0000 Subject: [issue3591] elementtree tests do not include bytes handling In-Reply-To: <1219078669.04.0.473516144349.issue3591@psf.upfronthosting.co.za> Message-ID: <1375361092.29.0.300392747744.issue3591@psf.upfronthosting.co.za> Eli Bendersky added the comment: Quite a bit of encoding-related tests were added recently (by Serhiy, IIRC). Unless there are objections or more specific test suggestions, I will close this issue in a few days. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 14:48:51 2013 From: report at bugs.python.org (Brett Cannon) Date: Thu, 01 Aug 2013 12:48:51 +0000 Subject: [issue18613] wrong float plus/minus op result In-Reply-To: <1375358511.45.0.0761593009905.issue18613@psf.upfronthosting.co.za> Message-ID: <1375361331.99.0.801693019965.issue18613@psf.upfronthosting.co.za> Brett Cannon added the comment: This is actually expected because that is just how floating point works in programming (see http://en.wikipedia.org/wiki/Floating_point for all the gnarly details). If you want exact decimal arithmetic, use the decimal module (which got significantly faster in Python 3.3):: >>> import decimal >>> decimal.Decimal('.3') - decimal.Decimal('.1') Decimal('0.2') >>> decimal.Decimal('.05') + decimal.Decimal('.01') Decimal('0.06') ---------- nosy: +brett.cannon resolution: -> invalid status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 14:48:57 2013 From: report at bugs.python.org (Eli Bendersky) Date: Thu, 01 Aug 2013 12:48:57 +0000 Subject: [issue13612] xml.etree.ElementTree says unknown encoding of a regular encoding In-Reply-To: <1324026251.51.0.0968835446575.issue13612@psf.upfronthosting.co.za> Message-ID: <1375361337.0.0.704639930477.issue13612@psf.upfronthosting.co.za> Eli Bendersky added the comment: Serhiy, do you want to backport the buffer overflow fix to 2.7? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 14:54:50 2013 From: report at bugs.python.org (Eli Bendersky) Date: Thu, 01 Aug 2013 12:54:50 +0000 Subject: [issue17372] provide pretty printer for xml.etree.ElementTree In-Reply-To: <1362640725.41.0.836381435016.issue17372@psf.upfronthosting.co.za> Message-ID: <1375361690.15.0.227137542864.issue17372@psf.upfronthosting.co.za> Eli Bendersky added the comment: Thanks for the report (Eric) and the patch (Alex). There are currently some open bugs we need to handle first, so this is somewhat lower priority. I hope to get to it before the 3.4 release. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 14:55:00 2013 From: report at bugs.python.org (Nick Coghlan) Date: Thu, 01 Aug 2013 12:55:00 +0000 Subject: [issue18472] Update PEP 8 to encourage modern conventions In-Reply-To: <1373973528.84.0.159091610788.issue18472@psf.upfronthosting.co.za> Message-ID: <1375361700.89.0.527525158552.issue18472@psf.upfronthosting.co.za> Changes by Nick Coghlan : ---------- resolution: -> fixed stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 14:59:13 2013 From: report at bugs.python.org (Nick Coghlan) Date: Thu, 01 Aug 2013 12:59:13 +0000 Subject: [issue18472] Update PEP 8 to encourage modern conventions In-Reply-To: <1373973528.84.0.159091610788.issue18472@psf.upfronthosting.co.za> Message-ID: <1375361953.8.0.480727275758.issue18472@psf.upfronthosting.co.za> Nick Coghlan added the comment: Heh, I just realised a correct generator definition would have needed the loop-and-a-half internally anyway: def itervalues(x): while True: value = x.getvalue() if not value: break yield value ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 15:00:44 2013 From: report at bugs.python.org (uglemat) Date: Thu, 01 Aug 2013 13:00:44 +0000 Subject: [issue18612] More elaborate documentation on how list comprehensions and generator expressions relate to each other In-Reply-To: <1375356212.93.0.797789110077.issue18612@psf.upfronthosting.co.za> Message-ID: <1375362044.65.0.916069751782.issue18612@psf.upfronthosting.co.za> uglemat added the comment: Yeah I think the differences are pretty easy to comprehend. To be honest the reason I came here is that I had an argument where someone commented on my code (where I used a generator expression) saying something akin to "list comprehensions are nice", so I replied "actually, that's a generator expression, which are very similar but behave differently". The response was that the two concepts are one and the same. I couldn't really say that that's incorrect, but I think it's very confusing for beginners if people are talking about generator expressions like they are list expressions because they behave so differently and the documentation for list comprehensions doesn't mention generator expressions. I was kind of longing for a definite answer so I could say "Nay, thou shall differentiate between list comprehensions and generator expressions". Is it right to correct someone and say that generator expressions are in fact *not* generator expressions? Maybe I'm blowing this out of proportions. :) ---------- versions: +Python 3.5 -Python 2.7, Python 3.3, Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 15:03:35 2013 From: report at bugs.python.org (Roundup Robot) Date: Thu, 01 Aug 2013 13:03:35 +0000 Subject: [issue9035] os.path.ismount on windows doesn't support windows mount points In-Reply-To: <1277023751.91.0.438330382261.issue9035@psf.upfronthosting.co.za> Message-ID: <3c5WsL5C8sz7Lkd@mail.python.org> Roundup Robot added the comment: New changeset 5258c4399f2e by Tim Golden in branch 'default': issue9035: Prevent Windows-specific tests from running on non-Windows platforms http://hg.python.org/cpython/rev/5258c4399f2e ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 15:03:46 2013 From: report at bugs.python.org (Richard Oudkerk) Date: Thu, 01 Aug 2013 13:03:46 +0000 Subject: [issue18214] Stop purging modules which are garbage collected before shutdown In-Reply-To: <1375359821.13.0.0215219004833.issue18214@psf.upfronthosting.co.za> Message-ID: <51FA5CA9.2080407@gmail.com> Richard Oudkerk added the comment: > Also, do note that purge/gc after wiping can still be a regular > gc pass unless the module has been wiped. The gc could be triggered > by another module being wiped. For me, the modules which die naturally after purging begins are # purge/gc encodings.aliases 34 # purge/gc _io 14 # purge/gc collections.abc 13 # purge/gc sre_compile 12 # purge/gc heapq 11 # purge/gc sre_constants 10 # purge/gc _weakrefset 9 # purge/gc reprlib 8 # purge/gc weakref 7 # purge/gc site 6 # purge/gc abc 5 # purge/gc encodings.latin_1 4 # purge/gc encodings.utf_8 3 # purge/gc genericpath 2 Of these, all but the first appear to happen during the final cyclic garbage collection. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 15:05:17 2013 From: report at bugs.python.org (Nick Coghlan) Date: Thu, 01 Aug 2013 13:05:17 +0000 Subject: [issue10434] Document the rules for "public names" In-Reply-To: <1289919338.9.0.394057770971.issue10434@psf.upfronthosting.co.za> Message-ID: <1375362317.81.0.560638431698.issue10434@psf.upfronthosting.co.za> Nick Coghlan added the comment: PEP 8 now covers the developer side of things: http://www.python.org/dev/peps/pep-0008/#public-and-internal-interfaces A user facing counterpart describing our backwards compatibility policy is still desirable. Updating PEP 5 wouldn't go astray, since that's *supposed* to serve that purpose :) ---------- nosy: +ncoghlan _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 15:05:31 2013 From: report at bugs.python.org (uglemat) Date: Thu, 01 Aug 2013 13:05:31 +0000 Subject: [issue18612] More elaborate documentation on how list comprehensions and generator expressions relate to each other In-Reply-To: <1375356212.93.0.797789110077.issue18612@psf.upfronthosting.co.za> Message-ID: <1375362331.76.0.275902634818.issue18612@psf.upfronthosting.co.za> uglemat added the comment: > Is it right to correct someone and say that generator expressions are in fact *not* generator expressions? Ups, I meant "Is it right to correct someone and say that generator expressions are in fact *not* list comprehensions?" All these expressions and comprehensions are making me dissy :) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 15:12:15 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 13:12:15 +0000 Subject: [issue18214] Stop purging modules which are garbage collected before shutdown In-Reply-To: <1371221979.53.0.00385452158182.issue18214@psf.upfronthosting.co.za> Message-ID: <1375362735.69.0.489638925149.issue18214@psf.upfronthosting.co.za> Antoine Pitrou added the comment: > Also, do note that purge/gc after wiping can still be a regular gc > pass unless the module has been wiped. The gc could be triggered by > another module being wiped. That said, I welcome any suggestions to improve things. The ultimate reasons we need to purge some modules are the same two reasons I indicated on python-dev: C extension modules are almost immortal; and some C code keeps references alive too long. Do you agree that this patch is ok and we should address those two problems in separate new issues? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 15:12:29 2013 From: report at bugs.python.org (Barry A. Warsaw) Date: Thu, 01 Aug 2013 13:12:29 +0000 Subject: [issue18472] Update PEP 8 to encourage modern conventions In-Reply-To: <1375359578.69.0.338177002419.issue18472@psf.upfronthosting.co.za> Message-ID: <20130801091230.7b13c883@anarchist> Barry A. Warsaw added the comment: On Aug 01, 2013, at 12:19 PM, Nick Coghlan wrote: >I *didn't* make any changes in relation to Barry's comment about having the >commentary intermixed with the guidelines. I quite like the notion of >stripping PEP 8 down to just the essentials and having PEP 108 as "The >annotated PEP 8", but that's a bigger project than I'm prepared to tackle >(heck, even the *current* patch turned out to be a far more substantial >update than I expected!). You've done great work on a substantial undertaking! Thanks. :) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 15:20:28 2013 From: report at bugs.python.org (R. David Murray) Date: Thu, 01 Aug 2013 13:20:28 +0000 Subject: [issue18612] More elaborate documentation on how list comprehensions and generator expressions relate to each other In-Reply-To: <1375356212.93.0.797789110077.issue18612@psf.upfronthosting.co.za> Message-ID: <1375363228.87.0.646528199026.issue18612@psf.upfronthosting.co.za> R. David Murray added the comment: Well, it is the case that if you substitute a list comprehension for a generator expression in arbitrary code, most of the time it would work but occasionally it wouldn't, because the runtime behavior is different (lazy production versus all-at-once production). So yes, the two are not the same thing, and it is important to understand the differences in behavior between them. Calling a generator expression a list comprehension indicates someone's mental model of how Python works has a couple holes in it, IMO :) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 15:30:02 2013 From: report at bugs.python.org (DLowell) Date: Thu, 01 Aug 2013 13:30:02 +0000 Subject: [issue14130] memoryview: add multi-dimensional indexing and slicing In-Reply-To: <1330259007.41.0.197339877072.issue14130@psf.upfronthosting.co.za> Message-ID: <1375363802.02.0.184353061124.issue14130@psf.upfronthosting.co.za> DLowell added the comment: Is this issue still being worked on? ---------- nosy: +DLowell _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 15:32:59 2013 From: report at bugs.python.org (Roundup Robot) Date: Thu, 01 Aug 2013 13:32:59 +0000 Subject: [issue18257] Two copies of python-config In-Reply-To: <1371567872.42.0.116049773773.issue18257@psf.upfronthosting.co.za> Message-ID: <3c5XWG69K7zPqh@mail.python.org> Roundup Robot added the comment: New changeset 7b165c7ab7ef by doko in branch 'default': - Issue #18257: Fix readlink usage in python-config. Install the python http://hg.python.org/cpython/rev/7b165c7ab7ef ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 15:35:25 2013 From: report at bugs.python.org (Matthias Klose) Date: Thu, 01 Aug 2013 13:35:25 +0000 Subject: [issue18257] Two copies of python-config In-Reply-To: <1371567872.42.0.116049773773.issue18257@psf.upfronthosting.co.za> Message-ID: <1375364125.12.0.38426165.issue18257@psf.upfronthosting.co.za> Matthias Klose added the comment: checked in a fix for the readlink issue, and Ronald's proposed solution for Darwin. And documented for now, that we do have two versions of this script. This works as long as you don't cross-build for Darwin or on Darwin. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 15:54:05 2013 From: report at bugs.python.org (Steven D'Aprano) Date: Thu, 01 Aug 2013 13:54:05 +0000 Subject: [issue18614] Enhanced \N{} escapes for Unicode strings Message-ID: <1375365245.12.0.441428484785.issue18614@psf.upfronthosting.co.za> New submission from Steven D'Aprano: As per the discussion here: http://mail.python.org/pipermail/python-ideas/2013-July/022419.html \N{} escapes should support the Unicode code point notation U+xxxx (where there are four, five or six hex digits after the U+). E.g. '\N{U+03BB}' => '?' unicodedata.lookup should also support such numeric names, e.g.: unicodedata.lookup('U+03BB') => '?' As '+' is otherwise prohibited in Unicode character names, there should never be ambiguity between 'U+xxxx' as a code point and an actual name, and a single lookup function can handle both. (See http://www.unicode.org/versions/Unicode6.2.0/ch04.pdf#G39 for details on characters allowed in names.) Also add a function for the reverse unicodedata.codepoint('?') => 'U+03BB' def codepoint(c): return 'U+{:04X}'.format(ord(c)) ---------- components: Unicode messages: 194075 nosy: ezio.melotti, stevenjd priority: normal severity: normal status: open title: Enhanced \N{} escapes for Unicode strings type: enhancement versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 16:14:55 2013 From: report at bugs.python.org (Richard Oudkerk) Date: Thu, 01 Aug 2013 14:14:55 +0000 Subject: [issue18214] Stop purging modules which are garbage collected before shutdown In-Reply-To: <1375362735.69.0.489638925149.issue18214@psf.upfronthosting.co.za> Message-ID: <51FA6D57.8070101@gmail.com> Richard Oudkerk added the comment: Yes, I agree the patch is ok. It would be would be much simpler to keep track of the module dicts if they were weakrefable. Alternatively, at shutdown a weakrefable object with a reference to the module dict could be inserted in to each module dict. We could then use those to find orphaned module dicts. But I doubt it is worth the extra effort. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 17:02:40 2013 From: report at bugs.python.org (Tim Golden) Date: Thu, 01 Aug 2013 15:02:40 +0000 Subject: [issue9035] os.path.ismount on windows doesn't support windows mount points In-Reply-To: <1277023751.91.0.438330382261.issue9035@psf.upfronthosting.co.za> Message-ID: <1375369360.66.0.688170660483.issue9035@psf.upfronthosting.co.za> Tim Golden added the comment: Fixed. Thanks for the patch ---------- resolution: -> fixed stage: needs patch -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 17:03:36 2013 From: report at bugs.python.org (Guido van Rossum) Date: Thu, 01 Aug 2013 15:03:36 +0000 Subject: [issue18472] Update PEP 8 to encourage modern conventions In-Reply-To: <20130801091230.7b13c883@anarchist> Message-ID: Guido van Rossum added the comment: Thanks a bundle, Nick! ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 17:14:06 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 15:14:06 +0000 Subject: [issue18214] Stop purging modules which are garbage collected before shutdown In-Reply-To: <1371221979.53.0.00385452158182.issue18214@psf.upfronthosting.co.za> Message-ID: <1375370046.78.0.645712211442.issue18214@psf.upfronthosting.co.za> Antoine Pitrou added the comment: Ok, let's attack the rest separately then :) And thanks a lot for testing! ---------- status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 17:17:55 2013 From: report at bugs.python.org (Claudiu.Popa) Date: Thu, 01 Aug 2013 15:17:55 +0000 Subject: [issue18615] sndhdr.whathdr could return a namedtuple Message-ID: <1375370275.79.0.808837089288.issue18615@psf.upfronthosting.co.za> New submission from Claudiu.Popa: Both sndhdr.whathdr an sndhdr.what returns a tuple with various information, while it could return a namedtuple. I attached a patched for this, with tests as well. ---------- components: Library (Lib) files: sndhdr.patch keywords: patch messages: 194080 nosy: Claudiu.Popa priority: normal severity: normal status: open title: sndhdr.whathdr could return a namedtuple type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file31110/sndhdr.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 17:42:50 2013 From: report at bugs.python.org (=?utf-8?q?Martin_v=2E_L=C3=B6wis?=) Date: Thu, 01 Aug 2013 15:42:50 +0000 Subject: [issue16111] Python 2.7.3 Windows MSI installer installs the VC++ 9 dlls directly to WinSxS folder In-Reply-To: <1349201780.49.0.563700308951.issue16111@psf.upfronthosting.co.za> Message-ID: <1375371770.74.0.0531211757687.issue16111@psf.upfronthosting.co.za> Martin v. L?wis added the comment: This is not true. Installing the modules into the SxS folder using the Merge Module (msm) is also a recommended way of installing the DLLs. I fail to see a problem in this report. ---------- nosy: +loewis _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 17:44:14 2013 From: report at bugs.python.org (=?utf-8?q?Martin_v=2E_L=C3=B6wis?=) Date: Thu, 01 Aug 2013 15:44:14 +0000 Subject: [issue3778] python uninstaller leave registry entries In-Reply-To: <1220562494.43.0.987039023455.issue3778@psf.upfronthosting.co.za> Message-ID: <1375371854.11.0.672860648349.issue3778@psf.upfronthosting.co.za> Martin v. L?wis added the comment: Nobody has contributed a patch in five years, so it apparently is pretty hard. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 17:56:02 2013 From: report at bugs.python.org (Derek Wilson) Date: Thu, 01 Aug 2013 15:56:02 +0000 Subject: [issue18616] enable more ssl socket options with get_server_certificate Message-ID: <1375372562.92.0.356754094449.issue18616@psf.upfronthosting.co.za> New submission from Derek Wilson: ssl.get_server_certificate does not allow advanced options like what ciphers to use (for ssl2 for instance) or SNI for virtual hosts with multiple ssl sites on one IP address. Adding **kwargs enables any current and future SSLSocket options to be passed along to the underlying connection. wrap_socket doesn't include all the options (npn and sni for instance), so I use SSLSocket instead. ---------- components: Extension Modules files: ssl_get_server_certificate_kwargs.patch keywords: patch messages: 194083 nosy: underrun priority: normal severity: normal status: open title: enable more ssl socket options with get_server_certificate type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file31111/ssl_get_server_certificate_kwargs.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 18:31:30 2013 From: report at bugs.python.org (Roundup Robot) Date: Thu, 01 Aug 2013 16:31:30 +0000 Subject: [issue18569] Set PATHEXT in the Windows installer In-Reply-To: <1374912463.83.0.476685307572.issue18569@psf.upfronthosting.co.za> Message-ID: <3c5cTF27Cvz7Lkn@mail.python.org> Roundup Robot added the comment: New changeset 2a38e4da6ce8 by Martin v. L?wis in branch 'default': Issue #18569: The installer now adds .py to the PATHEXT variable http://hg.python.org/cpython/rev/2a38e4da6ce8 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 18:32:43 2013 From: report at bugs.python.org (=?utf-8?q?Martin_v=2E_L=C3=B6wis?=) Date: Thu, 01 Aug 2013 16:32:43 +0000 Subject: [issue18569] Set PATHEXT in the Windows installer In-Reply-To: <1374912463.83.0.476685307572.issue18569@psf.upfronthosting.co.za> Message-ID: <1375374763.11.0.336099169989.issue18569@psf.upfronthosting.co.za> Martin v. L?wis added the comment: Thanks for the patch. It works fine (with the expected limitation that you need to restart running shells for this to take effect). ---------- resolution: -> fixed status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 18:45:06 2013 From: report at bugs.python.org (Guido van Rossum) Date: Thu, 01 Aug 2013 16:45:06 +0000 Subject: [issue18472] Update PEP 8 to encourage modern conventions In-Reply-To: <1373973528.84.0.159091610788.issue18472@psf.upfronthosting.co.za> Message-ID: <1375375506.16.0.964446779363.issue18472@psf.upfronthosting.co.za> Guido van Rossum added the comment: I think the current wording about line length makes it too easy to adopt 99 instead of 79. I propose to go back to 79 only, and add this before the paragraph starting with "The preferred way of wrapping long lines ..." """ Some teams strongly prefer a longer line length. For code maintained exclusively or primarily by a team that can reach agreement on this issue, it is okay to increase the line nominal line length from 80 to 100 characters (effectively increasing the maximum length to 99 characters), provided that comments and docstrings are still wrapped at 72 characters. """ ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 18:46:11 2013 From: report at bugs.python.org (Matthew Barnett) Date: Thu, 01 Aug 2013 16:46:11 +0000 Subject: [issue18614] Enhanced \N{} escapes for Unicode strings In-Reply-To: <1375365245.12.0.441428484785.issue18614@psf.upfronthosting.co.za> Message-ID: <1375375571.12.0.559855334061.issue18614@psf.upfronthosting.co.za> Matthew Barnett added the comment: I've attached a patch for this. ---------- keywords: +patch nosy: +mrabarnett Added file: http://bugs.python.org/file31112/issue18614.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 18:58:38 2013 From: report at bugs.python.org (Donald Stufft) Date: Thu, 01 Aug 2013 16:58:38 +0000 Subject: [issue18617] TLS and Intermediate Certificates Message-ID: <1375376317.99.0.429350247521.issue18617@psf.upfronthosting.co.za> New submission from Donald Stufft: Currently the Python SSL module requires the full chain, including all intermediaries, to be served in order to validate a TLS connection. This isn't *wrong* however a number of folks have had issues trying to setup a custom PyPI index in pip due to missing them. The believed the problem with validation to be in pip/Python because it works in their browser. Essentially browsers have the ability to download missing intermediate certs using an url found inside the AIA data. This is slow and isn't generally recommended that you rely on it for any particular site. However it does mean that TLS connections work in more situations. At the least this should probably be documented, and possibly the Python library be enhanced to be more browser like in this regard. ---------- components: Library (Lib) messages: 194088 nosy: dstufft priority: normal severity: normal status: open title: TLS and Intermediate Certificates type: enhancement _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 19:00:56 2013 From: report at bugs.python.org (Guido van Rossum) Date: Thu, 01 Aug 2013 17:00:56 +0000 Subject: [issue18472] Update PEP 8 to encourage modern conventions In-Reply-To: <1373973528.84.0.159091610788.issue18472@psf.upfronthosting.co.za> Message-ID: <1375376456.21.0.641644474143.issue18472@psf.upfronthosting.co.za> Guido van Rossum added the comment: See proposed patch at https://codereview.appspot.com/12269044/ . ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 19:09:05 2013 From: report at bugs.python.org (Christian Heimes) Date: Thu, 01 Aug 2013 17:09:05 +0000 Subject: [issue18617] TLS and Intermediate Certificates In-Reply-To: <1375376317.99.0.429350247521.issue18617@psf.upfronthosting.co.za> Message-ID: <1375376945.26.0.000835466375547.issue18617@psf.upfronthosting.co.za> Christian Heimes added the comment: Thx! Let's update the docs for 2.7 to 3.4 first. For AIA intermediate cert retrieval we have to use OpenSSL's verify hook. It's a pain to implement all necessary bits and hard to use, though. :( ---------- nosy: +christian.heimes versions: +Python 2.7, Python 3.3, Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 19:31:28 2013 From: report at bugs.python.org (Arfrever Frehtes Taifersar Arahesis) Date: Thu, 01 Aug 2013 17:31:28 +0000 Subject: [issue16248] Security bug in tkinter allows for untrusted, arbitrary code execution. In-Reply-To: <1350401361.69.0.96754494265.issue16248@psf.upfronthosting.co.za> Message-ID: <1375378288.18.0.687807032585.issue16248@psf.upfronthosting.co.za> Arfrever Frehtes Taifersar Arahesis added the comment: The fix in 2.6, 2.7, 3.1 and 3.2 branches introduced UnboundLocalError occurring when a non-None baseName parameter is passed. At least a part of fa82071bb7e1 should be backported to 2.6, 2.7, 3.1 and 3.2 branches. $ python2.7 -c 'import Tkinter; print(repr(Tkinter.Tk(baseName="some_name")))' Traceback (most recent call last): File "", line 1, in File "/usr/lib64/python2.7/lib-tk/Tkinter.py", line 1748, in __init__ if not sys.flags.ignore_environment: UnboundLocalError: local variable 'sys' referenced before assignment $ python3.2 -c 'import tkinter; print(repr(tkinter.Tk(baseName="some_name")))' Traceback (most recent call last): File "", line 1, in File "/usr/lib64/python3.2/tkinter/__init__.py", line 1734, in __init__ if not sys.flags.ignore_environment: UnboundLocalError: local variable 'sys' referenced before assignment ---------- resolution: fixed -> stage: committed/rejected -> status: closed -> open _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 19:41:18 2013 From: report at bugs.python.org (Arfrever Frehtes Taifersar Arahesis) Date: Thu, 01 Aug 2013 17:41:18 +0000 Subject: [issue18517] "xxlimited" extension declared incorrectly in setup.py In-Reply-To: <1374393760.41.0.977042124577.issue18517@psf.upfronthosting.co.za> Message-ID: <1375378878.36.0.355284029686.issue18517@psf.upfronthosting.co.za> Changes by Arfrever Frehtes Taifersar Arahesis : ---------- nosy: +Arfrever _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 19:47:43 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 17:47:43 +0000 Subject: [issue18618] Need an atexit.register equivalent that also works in subinterps Message-ID: <1375379263.55.0.273685957163.issue18618@psf.upfronthosting.co.za> New submission from Antoine Pitrou: Callbacks registered with atexit.register() are only called at shutdown of the main interpreter. For some purposes (perhaps most of them, arguably), you actually want to execute the callbacks at subinterpreter shutdown too. ---------- messages: 194092 nosy: pitrou, sbt priority: normal severity: normal status: open title: Need an atexit.register equivalent that also works in subinterps _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 19:47:58 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 17:47:58 +0000 Subject: [issue18618] Need an atexit.register equivalent that also works in subinterps In-Reply-To: <1375379263.55.0.273685957163.issue18618@psf.upfronthosting.co.za> Message-ID: <1375379278.08.0.128705658783.issue18618@psf.upfronthosting.co.za> Changes by Antoine Pitrou : ---------- components: +Interpreter Core, Library (Lib) priority: normal -> low type: -> enhancement versions: +Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 20:01:02 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 18:01:02 +0000 Subject: [issue18618] Need an atexit.register equivalent that also works in subinterps In-Reply-To: <1375379263.55.0.273685957163.issue18618@psf.upfronthosting.co.za> Message-ID: <1375380062.88.0.0658141371217.issue18618@psf.upfronthosting.co.za> Antoine Pitrou added the comment: (note that weakref.finalize indirectly suffers from this problem) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 20:03:55 2013 From: report at bugs.python.org (Larry Hastings) Date: Thu, 01 Aug 2013 18:03:55 +0000 Subject: [issue16248] Security bug in tkinter allows for untrusted, arbitrary code execution. In-Reply-To: <1350401361.69.0.96754494265.issue16248@psf.upfronthosting.co.za> Message-ID: <1375380235.14.0.035243219761.issue16248@psf.upfronthosting.co.za> Larry Hastings added the comment: You're talking about a new bug. Please open a new issue. I'm closing this issue right now because I want to cut a Python 3.4 alpha release tomorrow, and this bug is marked Python 3.4 and "release blocker". ---------- resolution: -> fixed status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 20:06:04 2013 From: report at bugs.python.org (Larry Hastings) Date: Thu, 01 Aug 2013 18:06:04 +0000 Subject: [issue17998] internal error in regular expression engine In-Reply-To: <1368803354.84.0.768428094886.issue17998@psf.upfronthosting.co.za> Message-ID: <1375380364.95.0.738353862845.issue17998@psf.upfronthosting.co.za> Larry Hastings added the comment: I'm downgrading this to "deferred blocker". I'm sure we'll get it fixed for Python 3.4 final, but in the meantime there's no sense in holding up Python 3.4a1 for it. ---------- priority: release blocker -> deferred blocker _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 20:08:18 2013 From: report at bugs.python.org (Arfrever Frehtes Taifersar Arahesis) Date: Thu, 01 Aug 2013 18:08:18 +0000 Subject: [issue16248] Security bug in tkinter allows for untrusted, arbitrary code execution. In-Reply-To: <1350401361.69.0.96754494265.issue16248@psf.upfronthosting.co.za> Message-ID: <1375380498.13.0.246213299662.issue16248@psf.upfronthosting.co.za> Arfrever Frehtes Taifersar Arahesis added the comment: UnboundLocalError is effect of partially incorrect fix for this bug. It is better to update Versions field. ---------- resolution: fixed -> status: closed -> open versions: +Python 3.1 -Python 3.3, Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 20:08:55 2013 From: report at bugs.python.org (Larry Hastings) Date: Thu, 01 Aug 2013 18:08:55 +0000 Subject: [issue18257] Two copies of python-config In-Reply-To: <1371567872.42.0.116049773773.issue18257@psf.upfronthosting.co.za> Message-ID: <1375380535.39.0.436473255007.issue18257@psf.upfronthosting.co.za> Larry Hastings added the comment: Thanks, Matthias! Now I can cut 3.4a1 on time. :) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 20:14:12 2013 From: report at bugs.python.org (Tshepang Lekhonkhobe) Date: Thu, 01 Aug 2013 18:14:12 +0000 Subject: [issue18472] Update PEP 8 to encourage modern conventions In-Reply-To: <1373973528.84.0.159091610788.issue18472@psf.upfronthosting.co.za> Message-ID: <1375380852.51.0.0632244943243.issue18472@psf.upfronthosting.co.za> Changes by Tshepang Lekhonkhobe : ---------- nosy: +tshepang _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 20:20:15 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 18:20:15 +0000 Subject: [issue18619] atexit leaks callbacks in subinterpreters Message-ID: <1375381215.71.0.728082521631.issue18619@psf.upfronthosting.co.za> New submission from Antoine Pitrou: atexit uses PEP 3121 module initialization, and by this scheme each subinterpreter gets a separate module state. However, atexit's m_free doesn't actually decref the callbacks: it only frees the callbacks array, thinking the callbacks were already decref'ed when run. This is ok at main interpreter shutdown, but not at subinterpreter shutdown (see issue 18618). ---------- components: Interpreter Core, Library (Lib) messages: 194098 nosy: Robin.Schreiber, pitrou, sbt priority: normal severity: normal stage: needs patch status: open title: atexit leaks callbacks in subinterpreters type: resource usage versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 20:23:49 2013 From: report at bugs.python.org (Tshepang Lekhonkhobe) Date: Thu, 01 Aug 2013 18:23:49 +0000 Subject: [issue18472] Update PEP 8 to encourage modern conventions In-Reply-To: <1373973528.84.0.159091610788.issue18472@psf.upfronthosting.co.za> Message-ID: <1375381429.96.0.0494241993953.issue18472@psf.upfronthosting.co.za> Tshepang Lekhonkhobe added the comment: @Guido am glad for the patch; it's a nice compromise ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 20:47:23 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 18:47:23 +0000 Subject: [issue18619] atexit leaks callbacks in subinterpreters In-Reply-To: <1375381215.71.0.728082521631.issue18619@psf.upfronthosting.co.za> Message-ID: <1375382843.42.0.579747708265.issue18619@psf.upfronthosting.co.za> Antoine Pitrou added the comment: Here is a patch. It also enables GC on the atexit module. ---------- keywords: +patch Added file: http://bugs.python.org/file31113/atexit_leaks.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 20:56:20 2013 From: report at bugs.python.org (Roundup Robot) Date: Thu, 01 Aug 2013 18:56:20 +0000 Subject: [issue18619] atexit leaks callbacks in subinterpreters In-Reply-To: <1375381215.71.0.728082521631.issue18619@psf.upfronthosting.co.za> Message-ID: <3c5ghN11v3z7LjN@mail.python.org> Roundup Robot added the comment: New changeset 71b63a32b1e3 by Antoine Pitrou in branch 'default': Issue #18619: Fix atexit leaking callbacks registered from sub-interpreters, and make it GC-aware. http://hg.python.org/cpython/rev/71b63a32b1e3 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 20:57:05 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 18:57:05 +0000 Subject: [issue18619] atexit leaks callbacks in subinterpreters In-Reply-To: <1375381215.71.0.728082521631.issue18619@psf.upfronthosting.co.za> Message-ID: <1375383425.29.0.132145507737.issue18619@psf.upfronthosting.co.za> Antoine Pitrou added the comment: The patch was simple enough that I decided to push it as-is :) Don't hesitate to make comments if you want, though. ---------- resolution: -> fixed stage: needs patch -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 21:05:17 2013 From: report at bugs.python.org (Roundup Robot) Date: Thu, 01 Aug 2013 19:05:17 +0000 Subject: [issue18608] Avoid keeping a strong reference to locale in the _io module In-Reply-To: <1375305631.67.0.684843179592.issue18608@psf.upfronthosting.co.za> Message-ID: <3c5gth6Ytjz7Ll1@mail.python.org> Roundup Robot added the comment: New changeset 1c9aa4f68f2b by Antoine Pitrou in branch 'default': Issue #18608: Avoid keeping a strong reference to the locale module inside the _io module. http://hg.python.org/cpython/rev/1c9aa4f68f2b ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 21:05:24 2013 From: report at bugs.python.org (Stephen Paul Chappell) Date: Thu, 01 Aug 2013 19:05:24 +0000 Subject: [issue18558] Iterable glossary entry needs clarification In-Reply-To: <1374796651.89.0.668716719647.issue18558@psf.upfronthosting.co.za> Message-ID: <1375383924.01.0.00621420986944.issue18558@psf.upfronthosting.co.za> Stephen Paul Chappell added the comment: If my program needed to know if an object is iterable, it would be tempting to define and call the following function instead of using collections.abc.Iterable: def iterable(obj): try: iter(obj) except TypeError: return False return True Something tells me that is not what the author of collections.abc.Iterable intended. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 21:05:47 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 19:05:47 +0000 Subject: [issue18608] Avoid keeping a strong reference to locale in the _io module In-Reply-To: <1375305631.67.0.684843179592.issue18608@psf.upfronthosting.co.za> Message-ID: <1375383947.1.0.987923623438.issue18608@psf.upfronthosting.co.za> Antoine Pitrou added the comment: Thanks Brett for reviewing. This is now pushed. ---------- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 21:14:54 2013 From: report at bugs.python.org (Roundup Robot) Date: Thu, 01 Aug 2013 19:14:54 +0000 Subject: [issue18589] cross-referencing doesn't work between the extending guide and c-api In-Reply-To: <1375122124.66.0.67649436332.issue18589@psf.upfronthosting.co.za> Message-ID: <3c5h5n4G35z7LjP@mail.python.org> Roundup Robot added the comment: New changeset a381721299a3 by Antoine Pitrou in branch '3.3': Issue #18589: fix hyperlinking of type slots (tp_*) http://hg.python.org/cpython/rev/a381721299a3 New changeset 36ff479e429c by Antoine Pitrou in branch 'default': Issue #18589: fix hyperlinking of type slots (tp_*) http://hg.python.org/cpython/rev/36ff479e429c ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 21:17:32 2013 From: report at bugs.python.org (Roundup Robot) Date: Thu, 01 Aug 2013 19:17:32 +0000 Subject: [issue18589] cross-referencing doesn't work between the extending guide and c-api In-Reply-To: <1375122124.66.0.67649436332.issue18589@psf.upfronthosting.co.za> Message-ID: <3c5h8q6c5xz7LjQ@mail.python.org> Roundup Robot added the comment: New changeset bb546f6d8ab4 by Antoine Pitrou in branch '2.7': Issue #18589: fix hyperlinking of type slots (tp_*) http://hg.python.org/cpython/rev/bb546f6d8ab4 ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 21:17:52 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 19:17:52 +0000 Subject: [issue18589] cross-referencing doesn't work between the extending guide and c-api In-Reply-To: <1375122124.66.0.67649436332.issue18589@psf.upfronthosting.co.za> Message-ID: <1375384672.2.0.200283013599.issue18589@psf.upfronthosting.co.za> Changes by Antoine Pitrou : ---------- resolution: -> fixed stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 21:54:02 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 19:54:02 +0000 Subject: [issue10241] gc fixes for module m_copy attribute In-Reply-To: <1288410530.83.0.095379048444.issue10241@psf.upfronthosting.co.za> Message-ID: <1375386842.25.0.82519149348.issue10241@psf.upfronthosting.co.za> Antoine Pitrou added the comment: Ok, the patch doesn't apply cleanly but looks good regardless. (although I wonder whether you really reclaim significant stuff here: most C extension dicts should be mostly references to C methods and types) ---------- assignee: loewis -> nosy: +pitrou type: behavior -> resource usage versions: +Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 22:06:02 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 20:06:02 +0000 Subject: [issue10241] gc fixes for module m_copy attribute In-Reply-To: <1288410530.83.0.095379048444.issue10241@psf.upfronthosting.co.za> Message-ID: <1375387562.76.0.308525813578.issue10241@psf.upfronthosting.co.za> Antoine Pitrou added the comment: I will still empty modules_by_index rather than Py_CLEAR it, though. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 22:07:15 2013 From: report at bugs.python.org (Roundup Robot) Date: Thu, 01 Aug 2013 20:07:15 +0000 Subject: [issue10241] gc fixes for module m_copy attribute In-Reply-To: <1288410530.83.0.095379048444.issue10241@psf.upfronthosting.co.za> Message-ID: <3c5jGB3hcsz7LjV@mail.python.org> Roundup Robot added the comment: New changeset 62658d9d8926 by Antoine Pitrou in branch 'default': Issue #10241: Clear extension module dict copies at interpreter shutdown. http://hg.python.org/cpython/rev/62658d9d8926 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 22:07:49 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 20:07:49 +0000 Subject: [issue10241] gc fixes for module m_copy attribute In-Reply-To: <1288410530.83.0.095379048444.issue10241@psf.upfronthosting.co.za> Message-ID: <1375387669.07.0.736852818983.issue10241@psf.upfronthosting.co.za> Changes by Antoine Pitrou : ---------- resolution: -> fixed stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 22:12:44 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 20:12:44 +0000 Subject: [issue18214] Stop purging modules which are garbage collected before shutdown In-Reply-To: <1371221979.53.0.00385452158182.issue18214@psf.upfronthosting.co.za> Message-ID: <1375387964.82.0.0258941277841.issue18214@psf.upfronthosting.co.za> Antoine Pitrou added the comment: By the way, you may be interested to learn that the patch in issue10241 has made things quite a bit better now: C extension modules can be collected much earlier. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 22:25:42 2013 From: report at bugs.python.org (Roundup Robot) Date: Thu, 01 Aug 2013 20:25:42 +0000 Subject: [issue16248] Security bug in tkinter allows for untrusted, arbitrary code execution. In-Reply-To: <1350401361.69.0.96754494265.issue16248@psf.upfronthosting.co.za> Message-ID: <3c5jgT3rlcz7LkD@mail.python.org> Roundup Robot added the comment: New changeset 0f17aed78168 by Antoine Pitrou in branch '2.7': Fix tkinter regression introduced by the security fix in #16248. http://hg.python.org/cpython/rev/0f17aed78168 ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 22:26:32 2013 From: report at bugs.python.org (R. David Murray) Date: Thu, 01 Aug 2013 20:26:32 +0000 Subject: [issue18558] Iterable glossary entry needs clarification In-Reply-To: <1374796651.89.0.668716719647.issue18558@psf.upfronthosting.co.za> Message-ID: <1375388792.26.0.533463547564.issue18558@psf.upfronthosting.co.za> R. David Murray added the comment: That would give you a false positive, though. It would return True for the 'y' in my example, which is not iterable. So Iterable's behavior here is an example of the Python design rule "resist the temptation to guess". As Terry said, new classes should implement an __iter__ method. The __getitem__ iteration support is for backward compatibility. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 22:27:07 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 20:27:07 +0000 Subject: [issue16248] Security bug in tkinter allows for untrusted, arbitrary code execution. In-Reply-To: <1350401361.69.0.96754494265.issue16248@psf.upfronthosting.co.za> Message-ID: <1375388827.85.0.531998330436.issue16248@psf.upfronthosting.co.za> Antoine Pitrou added the comment: I've committed a fix to 2.7 (I hope it's really a fix, since I don't know how to test it). I'll let Benjamin and Barry decide whether to backport to 2.6 and 3.2. As for 3.1, it's pretty much dead. ---------- priority: release blocker -> deferred blocker stage: -> committed/rejected versions: -Python 2.7, Python 3.1 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 22:30:44 2013 From: report at bugs.python.org (Chris Curvey) Date: Thu, 01 Aug 2013 20:30:44 +0000 Subject: [issue18620] multiprocessing page leaves out important part of Pool example Message-ID: <1375389044.82.0.349700607179.issue18620@psf.upfronthosting.co.za> New submission from Chris Curvey: on http://docs.python.org/2/library/multiprocessing.html, there is a bit about how to use a Pool properly, which looks like this pool = Pool(processes=4) # start 4 worker processes result = pool.apply_async(f, [10]) What this neglects to mention is that only one process will get any of the work. If you really want four processes in the pool to work, you have to call apply_async four times. For example: results = [] pool = Pool(processes=4) for i in xrange(4): results.append(pool.apply_async(f, [10])) hat tip to http://stackoverflow.com/questions/12483512/python-multiprocessing-apply-async-only-uses-one-process ---------- assignee: docs at python components: Documentation messages: 194115 nosy: Chris.Curvey, docs at python priority: normal severity: normal status: open title: multiprocessing page leaves out important part of Pool example type: enhancement _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 22:40:31 2013 From: report at bugs.python.org (Catalin Iacob) Date: Thu, 01 Aug 2013 20:40:31 +0000 Subject: [issue1294959] Problems with /usr/lib64 builds. Message-ID: <1375389631.59.0.4510977545.issue1294959@psf.upfronthosting.co.za> Changes by Catalin Iacob : ---------- nosy: +catalin.iacob _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 22:41:45 2013 From: report at bugs.python.org (John Jefferies) Date: Thu, 01 Aug 2013 20:41:45 +0000 Subject: [issue18306] os.stat gives exception for Windows junctions in v3.3 In-Reply-To: <1375355375.68.0.308421150629.issue18306@psf.upfronthosting.co.za> Message-ID: <51FAC853.6080805@ntlworld.com> John Jefferies added the comment: On 01/08/2013 12:09, Tim Golden wrote: > Tim Golden added the comment: > > I propose to close this one: using Python 3.3 on Win7 I can successfully stat NTFS Junctions. Is there any remaining issue? > > ---------- > > _______________________________________ > Python tracker > > _______________________________________ The original issue remains for me on v3.3.2. I can stat junctions in my user directory, but not in system directories. In v3.2 I can do that provided I am running with elevated privilege. If it's fixed in the next version that's great. ------------ Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> >>> import os >>> os.stat(r'C:\Windows\System32\config\systemprofile\SendTo') Traceback (most recent call last): File "", line 1, in FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Windows\\System32\\config\\systemprofile\\SendTo' >>> ------------ Regards John ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 22:49:56 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 20:49:56 +0000 Subject: [issue18621] site.py keeps too much stuff alive when it patches builtins Message-ID: <1375390196.76.0.0867903823381.issue18621@psf.upfronthosting.co.za> New submission from Antoine Pitrou: The site module patches the builtins module unless Python is run with -S. Unfortunately, this means the builtins dict then keeps the site module globals alive until the end of interpreter shutdown, preventing the garbage collection of many other objects or modules. Attached patch isolates those patched builtins inside a separate module "_sitebuiltins". ---------- components: Library (Lib) files: sitebuiltins.patch keywords: patch messages: 194117 nosy: pitrou, sbt priority: normal severity: normal stage: patch review status: open title: site.py keeps too much stuff alive when it patches builtins type: resource usage versions: Python 3.4 Added file: http://bugs.python.org/file31114/sitebuiltins.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 22:55:41 2013 From: report at bugs.python.org (Catalin Iacob) Date: Thu, 01 Aug 2013 20:55:41 +0000 Subject: [issue15631] Python 3.3/3.4 installation issue on OpenSUSE lib/lib64 folders In-Reply-To: <1344794304.26.0.478120841355.issue15631@psf.upfronthosting.co.za> Message-ID: <1375390541.98.0.965779742371.issue15631@psf.upfronthosting.co.za> Catalin Iacob added the comment: In reply to msg168184, LIBDIR is set to include lib64 instead of lib because openSUSE explicitly does it that way in their multilib implementation. More specifically, the CONFIG_SITE environment variable is set to /usr/share/site/x86_64-unknown-linux-gnu which contains, among more stuff: catalin at opensuse:~/hacking/cpython> cat $CONFIG_SITE | grep libdir # If user did not specify libdir, guess the correct target: if test "$libdir" = '${exec_prefix}/lib' ; then libdir='${exec_prefix}/lib64' /usr/share/site/x86_64-unknown-linux-gnu is owned by package site-config whose README says: site-config: Site Paths Configuration for autoconf Based configure Scripts ========================================================================== Site configuration for autoconf based configure scripts provides smart defaults for paths that are not specified. All autoconf based configure scripts will automatically resource site script using CONFIG_SITE environment variable. It works without any explicit user interaction. Currently implemented features: Automatic libdir setup to $exec_prefix/lib or $exec_prefix/lib64 ---------------------------------------------------------------- Depending on architecture, site script should correctly and automatically switch between lib and lib64 libdir. libexecdir setup to $exec_prefix/lib ------------------------------------ Upstream libexecdir defaults to $exec_prefix/libexec. This directory is not part of FHS 2.2, so we change it to $exec_prefix/lib (yes, it is correct to set it to $exec_prefix/lib even for bi-arch platforms). Most projects add package name to this path, so you most probably get what FHS 2.2 expects. ---------- nosy: +catalin.iacob _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 23:04:17 2013 From: report at bugs.python.org (Michael Foord) Date: Thu, 01 Aug 2013 21:04:17 +0000 Subject: [issue18622] reset_mock on mock created by mock_open causes infinite recursion Message-ID: <1375391057.28.0.108463427813.issue18622@psf.upfronthosting.co.za> New submission from Michael Foord: As reported at: http://code.google.com/p/mock/issues/detail?id=209 >>> from unittest import mock [107971 refs] >>> mock.mock_open [107974 refs] >>> a = mock.mock_open() [109965 refs] >>> a.reset_mock() ... ---------- assignee: michael.foord components: Library (Lib) keywords: easy messages: 194119 nosy: michael.foord priority: normal severity: normal stage: needs patch status: open title: reset_mock on mock created by mock_open causes infinite recursion type: behavior versions: Python 3.3, Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 23:23:29 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 21:23:29 +0000 Subject: [issue10241] gc fixes for module m_copy attribute In-Reply-To: <1288410530.83.0.095379048444.issue10241@psf.upfronthosting.co.za> Message-ID: <1375392209.12.0.898502235376.issue10241@psf.upfronthosting.co.za> Antoine Pitrou added the comment: Reopening. This seems to produce segfaults on several of the buildbots, e.g.: http://buildbot.python.org/all/builders/x86%20XP-4%203.x/builds/8947 http://buildbot.python.org/all/builders/x86%20Windows%20Server%202003%20%5BSB%5D%203.x/builds/1257 http://buildbot.python.org/all/builders/x86%20Gentoo%203.x/builds/4671 ---------- resolution: fixed -> status: closed -> open _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 23:39:39 2013 From: report at bugs.python.org (=?utf-8?q?Maciej_Blizi=C5=84ski?=) Date: Thu, 01 Aug 2013 21:39:39 +0000 Subject: [issue18605] 2.7: test_threading hangs on Solaris 9 In-Reply-To: <1375254182.2.0.923446047018.issue18605@psf.upfronthosting.co.za> Message-ID: <1375393179.55.0.844100486853.issue18605@psf.upfronthosting.co.za> Maciej Blizi?ski added the comment: Here's the output. After that output -- it hangs. == CPython 2.7.5 (default, Jul 30 2013, 01:41:03) [GCC 4.6.3] == Solaris-2.9-sun4u-sparc-32bit-ELF big-endian == /home/maciej/src/opencsw/pkg/lang-python/python/branches/python-2.7/work/solaris9-sparc/build-isa-sparcv8/Python-2.7.5/build/test_python_28299 Testing with flags: sys.flags(debug=0, py3k_warning=0, division_warning=0, division_new=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, tabcheck=0, verbose=0, unicode=0, bytes_warning=0, hash_randomization=0) test_threading test_acquire_contended (test.test_threading.LockTests) ... ok test_acquire_destroy (test.test_threading.LockTests) ... ok test_acquire_release (test.test_threading.LockTests) ... ok test_constructor (test.test_threading.LockTests) ... ok test_different_thread (test.test_threading.LockTests) ... ok test_reacquire (test.test_threading.LockTests) ... ok test_thread_leak (test.test_threading.LockTests) ... ok test_try_acquire (test.test_threading.LockTests) ... ok test_try_acquire_contended (test.test_threading.LockTests) ... ok test_with (test.test_threading.LockTests) ... ok test__is_owned (test.test_threading.RLockTests) ... ok test_acquire_contended (test.test_threading.RLockTests) ... ok test_acquire_destroy (test.test_threading.RLockTests) ... ok test_acquire_release (test.test_threading.RLockTests) ... ok test_constructor (test.test_threading.RLockTests) ... ok test_different_thread (test.test_threading.RLockTests) ... ok test_reacquire (test.test_threading.RLockTests) ... ok test_release_unacquired (test.test_threading.RLockTests) ... ok test_thread_leak (test.test_threading.RLockTests) ... ok test_try_acquire (test.test_threading.RLockTests) ... ok test_try_acquire_contended (test.test_threading.RLockTests) ... ok test_with (test.test_threading.RLockTests) ... ok test_is_set (test.test_threading.EventTests) ... ok test_notify (test.test_threading.EventTests) ... ok test_timeout (test.test_threading.EventTests) ... ok test__is_owned (test.test_threading.ConditionAsRLockTests) ... ok test_acquire_contended (test.test_threading.ConditionAsRLockTests) ... ok test_acquire_destroy (test.test_threading.ConditionAsRLockTests) ... ok test_acquire_release (test.test_threading.ConditionAsRLockTests) ... ok test_constructor (test.test_threading.ConditionAsRLockTests) ... ok test_different_thread (test.test_threading.ConditionAsRLockTests) ... ok test_reacquire (test.test_threading.ConditionAsRLockTests) ... ok test_release_unacquired (test.test_threading.ConditionAsRLockTests) ... ok test_thread_leak (test.test_threading.ConditionAsRLockTests) ... ok test_try_acquire (test.test_threading.ConditionAsRLockTests) ... ok test_try_acquire_contended (test.test_threading.ConditionAsRLockTests) ... ok test_with (test.test_threading.ConditionAsRLockTests) ... ok test_acquire (test.test_threading.ConditionTests) ... ok test_notify (test.test_threading.ConditionTests) ... ok test_timeout (test.test_threading.ConditionTests) ... ok test_unacquired_notify (test.test_threading.ConditionTests) ... ok test_unacquired_wait (test.test_threading.ConditionTests) ... ok test_acquire (test.test_threading.SemaphoreTests) ... ok test_acquire_contended (test.test_threading.SemaphoreTests) ... ok test_acquire_destroy (test.test_threading.SemaphoreTests) ... ok test_constructor (test.test_threading.SemaphoreTests) ... ok test_default_value (test.test_threading.SemaphoreTests) ... ok test_release_unacquired (test.test_threading.SemaphoreTests) ... ok test_try_acquire (test.test_threading.SemaphoreTests) ... ok test_try_acquire_contended (test.test_threading.SemaphoreTests) ... ok test_with (test.test_threading.SemaphoreTests) ... ok test_acquire (test.test_threading.BoundedSemaphoreTests) ... ok test_acquire_contended (test.test_threading.BoundedSemaphoreTests) ... ok test_acquire_destroy (test.test_threading.BoundedSemaphoreTests) ... ok test_constructor (test.test_threading.BoundedSemaphoreTests) ... ok test_default_value (test.test_threading.BoundedSemaphoreTests) ... ok test_recursion_limit (test.test_threading.BoundedSemaphoreTests) ... skipped 'test macosx problem' test_release_unacquired (test.test_threading.BoundedSemaphoreTests) ... ok test_try_acquire (test.test_threading.BoundedSemaphoreTests) ... ok test_try_acquire_contended (test.test_threading.BoundedSemaphoreTests) ... ok test_with (test.test_threading.BoundedSemaphoreTests) ... ok test_PyThreadState_SetAsyncExc (test.test_threading.ThreadTests) ... started worker thread trying nonsensical thread id waiting for worker thread to get started verifying worker hasn't exited attempting to raise asynch exception in worker waiting for worker to say it caught the exception all OK -- joining worker ok test_dummy_thread_after_fork (test.test_threading.ThreadTests) ... ok test_enumerate_after_join (test.test_threading.ThreadTests) ... ok test_finalize_runnning_thread (test.test_threading.ThreadTests) ... ok test_finalize_with_trace (test.test_threading.ThreadTests) ... ok test_foreign_thread (test.test_threading.ThreadTests) ... ok test_ident_of_no_threading_threads (test.test_threading.ThreadTests) ... ok test_join_nondaemon_on_shutdown (test.test_threading.ThreadTests) ... ok test_limbo_cleanup (test.test_threading.ThreadTests) ... ok test_no_refcycle_through_target (test.test_threading.ThreadTests) ... ok test_various_ops (test.test_threading.ThreadTests) ... task will run for 22.1 usec 1 tasks are runningtask will run for 20.0 usec 2 tasks are running task will run for 84.1 usec 3 tasks are running task will run for 66.9 usec task will run for 59.7 usec task will run for 70.5 usec task will run for 82.3 usec task will run for 62.1 usec task will run for 4.9 usec task will run for 85.3 usec waiting for all tasks to complete task done is finished. 2 tasks are running task done3 task tasks are running is finished. 2 tasks are running done3 tasks are running is finished. 2 tasks are running 3 tasks are running tasktask task done done done is finished. 2 tasks are running is finished. 1 tasks are running 2 tasks are running 3 tasks are running is finished. 2 tasks are running 3 tasks are running task done is finished. 2 tasks are running 3task task tasks are running done done is finished. 2 tasks are running is finished. 1 tasks are running task done is finished. 0 tasks are running all tasks done ok test_various_ops_large_stack (test.test_threading.ThreadTests) ... with 1MB thread stack size... task will run for 26.1 usec 1 task will run for 80.6 usec task will run for 83.7 usec tasks are running task will run for 33.4 usec2 tasks are running 3 tasks are running task will run for 14.3 usec task will run for 34.0 usec task will run for 3.4 usec task will run for 83.4 usec task will run for 49.6 usec task will run for 57.3 usec waiting for all tasks to complete task done is finished. 2 tasks are running 3 task done tasks are running is finished. 2 tasks are running 3 tasks are running task done is finished. 2 tasks are running 3 tasks are running task done is finished. 2 tasks are running 3 tasks are running task done is finished. 2 tasks are running 3 tasks are running task done is finished. 2 tasks are running 3 tasks are running task done is finished. 2 tasks are running 3 tasks are running task done is finished. 2 tasks are running task done is finished. 1 tasks are running task done is finished. 0 tasks are running all tasks done ok test_various_ops_small_stack (test.test_threading.ThreadTests) ... with 256kB thread stack size... task will run for 17.3 usec 1 tasks are running task will run for 95.0 usec 2 tasks are runningtask will run for 6.9 usec 3 tasks are running task will run for 0.0 usec task will run for 7.7 usec task will run for 57.2 usec task will run for 91.7 usec task will run for 40.6 usec tasktask will run for 92.3 usec donetask will run for 44.3 usec waiting for all tasks to complete is finished. 2 tasks are running task done is finished. 1 tasks are running 2 task tasks are running done3 task tasks are running done is finished. 2 tasks are running is finished. 1 tasks are running 2 tasks are running 3 tasks are running task done is finished. 2 tasks are running 3 tasks are running task done is finished. 2 tasks are running task done is finished. 1 tasks are running 2 tasks are running 3 tasks are running task done is finished. 2 tasks are running task done is finished. 1 tasks are running task done is finished. 0 tasks are running all tasks done ok test_1_join_on_shutdown (test.test_threading.ThreadJoinOnShutdown) ... ok test_2_join_in_forked_process (test.test_threading.ThreadJoinOnShutdown) ... ok test_3_join_in_forked_from_thread (test.test_threading.ThreadJoinOnShutdown) ... ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 23:46:12 2013 From: report at bugs.python.org (Stephen Paul Chappell) Date: Thu, 01 Aug 2013 21:46:12 +0000 Subject: [issue18558] Iterable glossary entry needs clarification In-Reply-To: <1374796651.89.0.668716719647.issue18558@psf.upfronthosting.co.za> Message-ID: <1375393572.01.0.442284358787.issue18558@psf.upfronthosting.co.za> Stephen Paul Chappell added the comment: Maybe this would have been more appropriate as a question on StackOverflow: What is the proper way of asking if an object is iterable if it does not support the iterator protocol but does support the old getitem protocol? One might argue that it is better to ask for forgiveness rather than permission, but that does not really answer the question. My impression of collections.abc.Iterable is that programmers can use it to ask if an object is iterable. Some argue that it is better to ask for forgiveness rather that permission and would suggest pretending that an object is iterable until it is proven otherwise. However, what do we use collections.abc.Iterable?s for then? The true question is really, ?What is the proper way of asking if an object is iterable if it does not support the iterator protocol but does support the old getitem protocol?? More generically, how can you ask an object if it supports ANY iteration protocol? The query probably should have been posted on StackOverflow and not here. This may not be a problem with collections.abc.Iterable, and thus the issue should be closed. However, the previous question remains, and it is apparent that it cannot be answered with the abstract class as it currently is. Maybe the solution is to just ask for forgiveness where appropriate. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 1 23:58:10 2013 From: report at bugs.python.org (Arfrever Frehtes Taifersar Arahesis) Date: Thu, 01 Aug 2013 21:58:10 +0000 Subject: [issue10241] gc fixes for module m_copy attribute In-Reply-To: <1288410530.83.0.095379048444.issue10241@psf.upfronthosting.co.za> Message-ID: <1375394290.24.0.513706159196.issue10241@psf.upfronthosting.co.za> Changes by Arfrever Frehtes Taifersar Arahesis : ---------- nosy: +Arfrever _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 00:04:55 2013 From: report at bugs.python.org (Terry J. Reedy) Date: Thu, 01 Aug 2013 22:04:55 +0000 Subject: [issue18614] Enhanced \N{} escapes for Unicode strings In-Reply-To: <1375365245.12.0.441428484785.issue18614@psf.upfronthosting.co.za> Message-ID: <1375394695.69.0.946219924984.issue18614@psf.upfronthosting.co.za> Terry J. Reedy added the comment: I agree with the proposal. Some of the code seems redundant with code we already have. In Python, I would write def codepoint_from_U_notation(name, namelen): if not (4 <= namelen <= 6): raise return chr(int(name, 16)) maybe with try-except to re-write error messages like ValueError: invalid literal for int() with base 16: '99x3' ValueError: chr() arg not in range(0x110000) My point is that we already have code to convert hex strings to int; I presume PyUnicode_FromOrdinal(code) is the C version of 'chr' that already checks the max value. ---------- nosy: +terry.reedy _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 00:07:03 2013 From: report at bugs.python.org (=?utf-8?q?Martin_v=2E_L=C3=B6wis?=) Date: Thu, 01 Aug 2013 22:07:03 +0000 Subject: [issue18023] msi product code for 2.7.5150 not in Tools/msi/uuids.py In-Reply-To: <1369079762.11.0.597354582837.issue18023@psf.upfronthosting.co.za> Message-ID: <1375394823.38.0.606602277175.issue18023@psf.upfronthosting.co.za> Martin v. L?wis added the comment: I have now added the uuid. ---------- resolution: -> fixed status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 00:12:28 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 22:12:28 +0000 Subject: [issue18623] Factor out the _SuppressCoreFiles context manager Message-ID: <1375395147.99.0.182035967047.issue18623@psf.upfronthosting.co.za> New submission from Antoine Pitrou: _SuppressCoreFiles in test_subprocess is a useful facility for other tests, for instance test_faulthandler (which has its own logic) or test_capi (which actually happily dumps core in one of its subtests). It could probably be factored out into test.support. ---------- components: Tests keywords: easy messages: 194125 nosy: ezio.melotti, ncoghlan, pitrou priority: normal severity: normal stage: needs patch status: open title: Factor out the _SuppressCoreFiles context manager type: enhancement versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 00:15:16 2013 From: report at bugs.python.org (STINNER Victor) Date: Thu, 01 Aug 2013 22:15:16 +0000 Subject: [issue18623] Factor out the _SuppressCoreFiles context manager In-Reply-To: <1375395147.99.0.182035967047.issue18623@psf.upfronthosting.co.za> Message-ID: <1375395316.65.0.752034557399.issue18623@psf.upfronthosting.co.za> Changes by STINNER Victor : ---------- nosy: +haypo _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 00:31:08 2013 From: report at bugs.python.org (Ned Deily) Date: Thu, 01 Aug 2013 22:31:08 +0000 Subject: [issue16463] testConnectTimeout of test_timeout TCPTimeoutTestCasefailures fails intermittently In-Reply-To: <1352757217.25.0.912881014186.issue16463@psf.upfronthosting.co.za> Message-ID: <1375396268.06.0.269486862523.issue16463@psf.upfronthosting.co.za> Ned Deily added the comment: Also fails occasionally on OS X 3.3 and 3.x with much smaller deltas: ====================================================================== FAIL: testConnectTimeout (test.test_timeout.TCPTimeoutTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/db3l/buildarea/3.3.bolen-tiger/build/Lib/test/test_timeout.py", line 222, in testConnectTimeout self._sock_operation(1, 0.001, 'connect', self.addr_remote) File "/Users/db3l/buildarea/3.3.bolen-tiger/build/Lib/test/test_timeout.py", line 126, in _sock_operation self.assertLess(delta, timeout + self.fuzz) AssertionError: 2.0828001499176025 not less than 2.001 ====================================================================== FAIL: testConnectTimeout (test.test_timeout.TCPTimeoutTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/test/test_timeout.py", line 222, in testConnectTimeout self._sock_operation(1, 0.001, 'connect', self.addr_remote) File "/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/test/test_timeout.py", line 126, in _sock_operation self.assertLess(delta, timeout + self.fuzz) AssertionError: 2.0782082080841064 not less than 2.001 ---------- nosy: +ned.deily, trent stage: -> needs patch title: test_timeout failure on the RHEL buildbot -> testConnectTimeout of test_timeout TCPTimeoutTestCasefailures fails intermittently versions: -Python 3.2 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 00:32:15 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 22:32:15 +0000 Subject: [issue10241] gc fixes for module m_copy attribute In-Reply-To: <1288410530.83.0.095379048444.issue10241@psf.upfronthosting.co.za> Message-ID: <1375396335.82.0.432900350427.issue10241@psf.upfronthosting.co.za> Antoine Pitrou added the comment: I managed to get a core dump locally. Interestingly, it may be that the _tk module is the culprit. The backtrace is the following: #0 0x00007ff6c5e14aab in raise () from /lib/x86_64-linux-gnu/libpthread.so.0 #1 0x000000000044e57e in faulthandler_fatal_error (signum=11) at ./Modules/faulthandler.c:305 #2 #3 0x00000000004c085e in _Py_Dealloc (op=) at Objects/object.c:1873 #4 0x00000000004a8085 in free_keys_object (keys=0x3100ab0) at Objects/dictobject.c:378 #5 0x00000000004ab0e8 in dict_dealloc (mp=0x7ff6be6194b8) at Objects/dictobject.c:1400 #6 0x00000000004c0860 in _Py_Dealloc ( op={'children': , 'master': None, 'tk': , '_tkloaded': 1, '_tclCommands': None}) at Objects/object.c:1873 #7 0x00000000004d7ac7 in subtype_dealloc ( self=, master=None, tk=, _tkloaded=1, _tclCommands=None) at remote 0x7ff6bc9a7dc0>) at Objects/typeobject.c:1049 #8 0x00000000004c0860 in _Py_Dealloc ( op=, master=None, tk=, _tkloaded=1, _tclCommands=None) at remote 0x7ff6bc9a7dc0>) at Objects/object.c:1873 #9 0x00000000004a8085 in free_keys_object (keys=0x3100e40) at Objects/dictobject.c:378 #10 0x00000000004aac8f in PyDict_Clear (op={}) at Objects/dictobject.c:1291 #11 0x00000000004dd9c8 in type_clear (type=0x14f45b8) at Objects/typeobject.c:2981 #12 0x000000000043a703 in delete_garbage (collectable=0x7fffab364300, old=0x8de7c0 ) at Modules/gcmodule.c:854 #13 0x000000000043ac9d in collect (generation=2, n_collected=0x0, n_uncollectable=0x0, nofail=1) at Modules/gcmodule.c:1020 #14 0x000000000043bfa3 in _PyGC_CollectNoFail () at Modules/gcmodule.c:1619 #15 0x00000000005c6cb6 in PyImport_Cleanup () at Python/import.c:420 #16 0x000000000041d992 in Py_Finalize () at Python/pythonrun.c:552 #17 0x000000000042392b in Py_Exit (sts=0) at Python/pythonrun.c:2474 #18 0x000000000042114b in handle_system_exit () at Python/pythonrun.c:1673 #19 0x0000000000421176 in PyErr_PrintEx (set_sys_last_vars=1) at Python/pythonrun.c:1683 #20 0x0000000000420ddd in PyErr_Print () at Python/pythonrun.c:1590 #21 0x0000000000437fc4 in RunModule (modname=0xf4d570 L"test", set_argv0=1) at Modules/main.c:227 #22 0x0000000000439279 in Py_Main (argc=18, argv=0xf4c020) at Modules/main.c:715 #23 0x00000000004199b5 in main (argc=18, argv=0x7fffab364908) at ./Modules/python.c:69 ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 00:34:14 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 22:34:14 +0000 Subject: [issue18623] Factor out the _SuppressCoreFiles context manager In-Reply-To: <1375395147.99.0.182035967047.issue18623@psf.upfronthosting.co.za> Message-ID: <1375396454.14.0.499553880831.issue18623@psf.upfronthosting.co.za> Antoine Pitrou added the comment: Ah, and the recursion limit tests in test_sys dump core too... ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 00:49:43 2013 From: report at bugs.python.org (Roundup Robot) Date: Thu, 01 Aug 2013 22:49:43 +0000 Subject: [issue18408] Fixes crashes found by pyfailmalloc In-Reply-To: <1373314243.02.0.649080681154.issue18408@psf.upfronthosting.co.za> Message-ID: <3c5msg0kZsz7Ljc@mail.python.org> Roundup Robot added the comment: New changeset de1ea7f84e08 by Victor Stinner in branch 'default': Issue #18609, #18408: _ctypes_add_traceback() now clears the current exception http://hg.python.org/cpython/rev/de1ea7f84e08 ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 00:49:44 2013 From: report at bugs.python.org (Roundup Robot) Date: Thu, 01 Aug 2013 22:49:44 +0000 Subject: [issue18609] test_ctypes failure on AIX in PyEval_CallObjectWithKeywords In-Reply-To: <1375305877.13.0.891928742401.issue18609@psf.upfronthosting.co.za> Message-ID: <3c5msg67gpz7Ljc@mail.python.org> Roundup Robot added the comment: New changeset de1ea7f84e08 by Victor Stinner in branch 'default': Issue #18609, #18408: _ctypes_add_traceback() now clears the current exception http://hg.python.org/cpython/rev/de1ea7f84e08 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 00:50:59 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 01 Aug 2013 22:50:59 +0000 Subject: [issue10241] gc fixes for module m_copy attribute In-Reply-To: <1288410530.83.0.095379048444.issue10241@psf.upfronthosting.co.za> Message-ID: <1375397459.11.0.0602476120234.issue10241@psf.upfronthosting.co.za> Antoine Pitrou added the comment: _tkinter uses PyType_FromSpec() to create its types and then adds them to the module dict without increfing them, so there may be a refcount issue explaining that those types get garbage collected before all their instances die. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 00:56:38 2013 From: report at bugs.python.org (STINNER Victor) Date: Thu, 01 Aug 2013 22:56:38 +0000 Subject: [issue18609] test_ctypes failure on AIX in PyEval_CallObjectWithKeywords In-Reply-To: <1375305877.13.0.891928742401.issue18609@psf.upfronthosting.co.za> Message-ID: <1375397798.7.0.825717532043.issue18609@psf.upfronthosting.co.za> STINNER Victor added the comment: This issue is not a bug, but a new assertion added by myself for the issue #18408. The idea is to not call a Python function with an exception set, because the exception may be cleared or replaced (ex: hasattr() clears the current exception if an attribute is not found). I didn't see this specific issue because AIX is using a special locale setting. Its locale encoding is an alias of the ISO-8859-1 which is not known by PyUnicode_Decode(). I'm waiting for the buildbot to see if my changeset fixed the issue. If it does, I will also add a fast-path for the "iso8859-1" alias of the ISO-8859-1 codec in PyUnicode_Decode(). So the AIX buildbot will also use the C implementation of the codec. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 01:00:07 2013 From: report at bugs.python.org (=?utf-8?q?Maciej_Blizi=C5=84ski?=) Date: Thu, 01 Aug 2013 23:00:07 +0000 Subject: [issue18605] 2.7: test_threading hangs on Solaris 9 In-Reply-To: <1375254182.2.0.923446047018.issue18605@psf.upfronthosting.co.za> Message-ID: <1375398007.45.0.628972001828.issue18605@psf.upfronthosting.co.za> Maciej Blizi?ski added the comment: Test results for sources pulled from the mercurial repository: they hang in the same place. == CPython 3.4.0a0 (default, Aug 2 2013, 00:38:45) [GCC 4.6.3] == Solaris-2.9-sun4u-sparc-32bit-ELF big-endian == /home/maciej/src/cpython/build/test_python_19419 Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1) [1/1] test_threading test_abort (test.test_threading.BarrierTests) ... ok test_abort_and_reset (test.test_threading.BarrierTests) ... ok test_action (test.test_threading.BarrierTests) ... ok test_barrier (test.test_threading.BarrierTests) ... ok test_barrier_10 (test.test_threading.BarrierTests) ... ok test_default_timeout (test.test_threading.BarrierTests) ... ok test_reset (test.test_threading.BarrierTests) ... ok test_single_thread (test.test_threading.BarrierTests) ... ok test_timeout (test.test_threading.BarrierTests) ... ok test_wait_return (test.test_threading.BarrierTests) ... ok test_acquire (test.test_threading.BoundedSemaphoreTests) ... ok test_acquire_contended (test.test_threading.BoundedSemaphoreTests) ... ok test_acquire_destroy (test.test_threading.BoundedSemaphoreTests) ... ok test_acquire_timeout (test.test_threading.BoundedSemaphoreTests) ... ok test_constructor (test.test_threading.BoundedSemaphoreTests) ... ok test_default_value (test.test_threading.BoundedSemaphoreTests) ... ok test_release_unacquired (test.test_threading.BoundedSemaphoreTests) ... ok test_try_acquire (test.test_threading.BoundedSemaphoreTests) ... ok test_try_acquire_contended (test.test_threading.BoundedSemaphoreTests) ... ok test_with (test.test_threading.BoundedSemaphoreTests) ... ok test__is_owned (test.test_threading.CRLockTests) ... ok test_acquire_contended (test.test_threading.CRLockTests) ... ok test_acquire_destroy (test.test_threading.CRLockTests) ... ok test_acquire_release (test.test_threading.CRLockTests) ... ok test_constructor (test.test_threading.CRLockTests) ... ok test_different_thread (test.test_threading.CRLockTests) ... ok test_reacquire (test.test_threading.CRLockTests) ... ok test_release_save_unacquired (test.test_threading.CRLockTests) ... ok test_release_unacquired (test.test_threading.CRLockTests) ... ok test_repr (test.test_threading.CRLockTests) ... ok test_thread_leak (test.test_threading.CRLockTests) ... ok test_timeout (test.test_threading.CRLockTests) ... ok test_try_acquire (test.test_threading.CRLockTests) ... ok test_try_acquire_contended (test.test_threading.CRLockTests) ... ok test_with (test.test_threading.CRLockTests) ... ok test__is_owned (test.test_threading.ConditionAsRLockTests) ... ok test_acquire_contended (test.test_threading.ConditionAsRLockTests) ... ok test_acquire_destroy (test.test_threading.ConditionAsRLockTests) ... ok test_acquire_release (test.test_threading.ConditionAsRLockTests) ... ok test_constructor (test.test_threading.ConditionAsRLockTests) ... ok test_different_thread (test.test_threading.ConditionAsRLockTests) ... ok test_reacquire (test.test_threading.ConditionAsRLockTests) ... ok test_release_save_unacquired (test.test_threading.ConditionAsRLockTests) ... ok test_release_unacquired (test.test_threading.ConditionAsRLockTests) ... ok test_repr (test.test_threading.ConditionAsRLockTests) ... ok test_thread_leak (test.test_threading.ConditionAsRLockTests) ... ok test_timeout (test.test_threading.ConditionAsRLockTests) ... ok test_try_acquire (test.test_threading.ConditionAsRLockTests) ... ok test_try_acquire_contended (test.test_threading.ConditionAsRLockTests) ... ok test_with (test.test_threading.ConditionAsRLockTests) ... ok test_acquire (test.test_threading.ConditionTests) ... ok test_notify (test.test_threading.ConditionTests) ... ok test_timeout (test.test_threading.ConditionTests) ... ok test_unacquired_notify (test.test_threading.ConditionTests) ... ok test_unacquired_wait (test.test_threading.ConditionTests) ... ok test_waitfor (test.test_threading.ConditionTests) ... ok test_waitfor_timeout (test.test_threading.ConditionTests) ... ok test_is_set (test.test_threading.EventTests) ... ok test_notify (test.test_threading.EventTests) ... ok test_set_and_clear (test.test_threading.EventTests) ... ok test_timeout (test.test_threading.EventTests) ... ok test_acquire_contended (test.test_threading.LockTests) ... ok test_acquire_destroy (test.test_threading.LockTests) ... ok test_acquire_release (test.test_threading.LockTests) ... ok test_constructor (test.test_threading.LockTests) ... ok test_different_thread (test.test_threading.LockTests) ... ok test_reacquire (test.test_threading.LockTests) ... ok test_repr (test.test_threading.LockTests) ... ok test_state_after_timeout (test.test_threading.LockTests) ... ok test_thread_leak (test.test_threading.LockTests) ... ok test_timeout (test.test_threading.LockTests) ... ok test_try_acquire (test.test_threading.LockTests) ... ok test_try_acquire_contended (test.test_threading.LockTests) ... ok test_with (test.test_threading.LockTests) ... ok test__is_owned (test.test_threading.PyRLockTests) ... ok test_acquire_contended (test.test_threading.PyRLockTests) ... ok test_acquire_destroy (test.test_threading.PyRLockTests) ... ok test_acquire_release (test.test_threading.PyRLockTests) ... ok test_constructor (test.test_threading.PyRLockTests) ... ok test_different_thread (test.test_threading.PyRLockTests) ... ok test_reacquire (test.test_threading.PyRLockTests) ... ok test_release_save_unacquired (test.test_threading.PyRLockTests) ... ok test_release_unacquired (test.test_threading.PyRLockTests) ... ok test_repr (test.test_threading.PyRLockTests) ... ok test_thread_leak (test.test_threading.PyRLockTests) ... ok test_timeout (test.test_threading.PyRLockTests) ... ok test_try_acquire (test.test_threading.PyRLockTests) ... ok test_try_acquire_contended (test.test_threading.PyRLockTests) ... ok test_with (test.test_threading.PyRLockTests) ... ok test_acquire (test.test_threading.SemaphoreTests) ... ok test_acquire_contended (test.test_threading.SemaphoreTests) ... ok test_acquire_destroy (test.test_threading.SemaphoreTests) ... ok test_acquire_timeout (test.test_threading.SemaphoreTests) ... ok test_constructor (test.test_threading.SemaphoreTests) ... ok test_default_value (test.test_threading.SemaphoreTests) ... ok test_release_unacquired (test.test_threading.SemaphoreTests) ... ok test_try_acquire (test.test_threading.SemaphoreTests) ... ok test_try_acquire_contended (test.test_threading.SemaphoreTests) ... ok test_with (test.test_threading.SemaphoreTests) ... ok test_1_join_on_shutdown (test.test_threading.ThreadJoinOnShutdown) ... ok test_2_join_in_forked_process (test.test_threading.ThreadJoinOnShutdown) ... ok test_3_join_in_forked_from_thread (test.test_threading.ThreadJoinOnShutdown) ... ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 01:04:29 2013 From: report at bugs.python.org (R. David Murray) Date: Thu, 01 Aug 2013 23:04:29 +0000 Subject: [issue18624] Add alias for iso-8859-8-i which is the same as iso-8859-8 Message-ID: <1375398269.06.0.0330535739148.issue18624@psf.upfronthosting.co.za> New submission from R. David Murray: Emails and web pages may specify a character set of iso-8859-8-i, which has exactly the same code points as iso-8859-8. The -i has to do with how bi-directional text is handled, but doesn't affect the encoding: http://lists.w3.org/Archives/Public/www-validator/2001Apr/0008.html ---------- components: Unicode, email keywords: easy messages: 194134 nosy: barry, ezio.melotti, r.david.murray priority: normal severity: normal stage: needs patch status: open title: Add alias for iso-8859-8-i which is the same as iso-8859-8 type: enhancement versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 01:29:18 2013 From: report at bugs.python.org (R. David Murray) Date: Thu, 01 Aug 2013 23:29:18 +0000 Subject: [issue18558] Iterable glossary entry needs clarification In-Reply-To: <1374796651.89.0.668716719647.issue18558@psf.upfronthosting.co.za> Message-ID: <1375399758.79.0.488038477513.issue18558@psf.upfronthosting.co.za> R. David Murray added the comment: ?What is the proper way of asking if an object is iterable if it does not support the iterator protocol but does support the old getitem protocol?? The *only* answer to that question is to try to iterate it, and see if you get a KeyError on "0". Since this results in obtaining the first element if it *is* iterable, and in the general case you cannot "reset" an iterable, there is no way to look before you leap. You have to catch the error after it occurs. This question and answer probably do belong on Stack Overflow or python-list, but the glossary entry still needs improvement, since the Iterable docs reference it :) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 01:35:54 2013 From: report at bugs.python.org (STINNER Victor) Date: Thu, 01 Aug 2013 23:35:54 +0000 Subject: [issue18519] test_sqlite crashes on OS X tiger 3.x buildbot In-Reply-To: <1374400670.71.0.678852160853.issue18519@psf.upfronthosting.co.za> Message-ID: <1375400154.08.0.824485161104.issue18519@psf.upfronthosting.co.za> STINNER Victor added the comment: ned> The changes for this issue appear to have changed the behavior of test_sqlite. David> Heh, that's the kind of behavior change I was worried about :( I don't understand why the test is failing, nor why it is only failing on one specific buildbot. Does it mean that 5/0 does not raise an exception on this specific buildbot? I don't understand the relation between my changesets and this failure. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 01:44:13 2013 From: report at bugs.python.org (Kevin Harms) Date: Thu, 01 Aug 2013 23:44:13 +0000 Subject: [issue14956] custom PYTHONPATH may break apps embedding Python In-Reply-To: <1338321412.45.0.331737203349.issue14956@psf.upfronthosting.co.za> Message-ID: <1375400653.72.0.512111597617.issue14956@psf.upfronthosting.co.za> Kevin Harms added the comment: As far as I can tell, this issue is not resolved. It would be very nice for the C API to have the equivalent for -E for security reasons. I would like to make a setgid binary and do not want users to be able to set PYTHON* variables to force loading of custom code. ---------- nosy: +Kevin.Harms _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 01:48:32 2013 From: report at bugs.python.org (Roundup Robot) Date: Thu, 01 Aug 2013 23:48:32 +0000 Subject: [issue18519] test_sqlite crashes on OS X tiger 3.x buildbot In-Reply-To: <1374400670.71.0.678852160853.issue18519@psf.upfronthosting.co.za> Message-ID: <3c5p9X1JG2zNPH@mail.python.org> Roundup Robot added the comment: New changeset c73f4dced6aa by Victor Stinner in branch 'default': Issue #18519: Fix test_sqlite on old versions of libsqlite3 http://hg.python.org/cpython/rev/c73f4dced6aa ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 01:54:04 2013 From: report at bugs.python.org (R. David Murray) Date: Thu, 01 Aug 2013 23:54:04 +0000 Subject: [issue18625] ks_c-5601-1987 is used by microsoft when it really means cp949 Message-ID: <1375401244.03.0.758628896825.issue18625@psf.upfronthosting.co.za> New submission from R. David Murray: When Microsoft handles Korean text, it uses its own code page, cp949, which is a superset of ks_c-5601-1987. But when talking to the rest of the world, it claims that the character set name is ks_c-5601-1987. This means that text claimed to be in ks_c-5601-1987 in email messages (and probably on web pages) can't always be decoded using the codec that ks_c-5601-1987 maps to (euc_kr). [*] This problem shows up in the real world in email. If non euc_kr characters are used, email will try blow up when trying to decode the ostensibly ks_c-5601-1987 text. (I'm not sure if it will also blow up trying to encode it, I'm not sure what characters the two codecs cover.) I'm not sure what the best solution is, but one possibility would be to add a "fixup" table to email that would cause it to decode ostensibly ks_c-5601-1987 text using the cp949 codec. Since cp949 is a superset, this should at least solve the input side. [*] Some relevant standards discussion: http://lists.w3.org/Archives/Public/ietf-charsets/2001AprJun/0033.html >From this, it isn't clear why we map ks_c-5601-1987 to euc_kr, since they at least appear to be different codecs. I haven't looked at the relevant RFCs to see what the differences are, though. ---------- components: Unicode, email messages: 194139 nosy: barry, ezio.melotti, r.david.murray priority: normal severity: normal status: open title: ks_c-5601-1987 is used by microsoft when it really means cp949 type: enhancement versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 02:02:46 2013 From: report at bugs.python.org (STINNER Victor) Date: Fri, 02 Aug 2013 00:02:46 +0000 Subject: [issue18519] test_sqlite crashes on OS X tiger 3.x buildbot In-Reply-To: <3c5p9X1JG2zNPH@mail.python.org> Message-ID: STINNER Victor added the comment: > I don't understand the relation between my changesets and this failure. Ok, I found the reason in the definition of the _sqlite3_result_error() function. This function behave differently on old sqlite versions: it raises a new exception. The issue should now be fixed, can you please try on your Tiger box? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 02:08:09 2013 From: report at bugs.python.org (Ned Deily) Date: Fri, 02 Aug 2013 00:08:09 +0000 Subject: [issue18519] test_sqlite crashes on OS X tiger 3.x buildbot In-Reply-To: <1374400670.71.0.678852160853.issue18519@psf.upfronthosting.co.za> Message-ID: <1375402089.71.0.471760343372.issue18519@psf.upfronthosting.co.za> Ned Deily added the comment: c73f4dced6aa appears to fix the problem on 10.4 Tiger. Thanks! ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 02:09:28 2013 From: report at bugs.python.org (STINNER Victor) Date: Fri, 02 Aug 2013 00:09:28 +0000 Subject: [issue18519] test_sqlite crashes on OS X tiger 3.x buildbot In-Reply-To: <1374400670.71.0.678852160853.issue18519@psf.upfronthosting.co.za> Message-ID: <1375402168.16.0.972336366861.issue18519@psf.upfronthosting.co.za> STINNER Victor added the comment: There is no more known bug, i'm closing this issue. ---------- resolution: -> fixed status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 02:32:30 2013 From: report at bugs.python.org (Demian Brecht) Date: Fri, 02 Aug 2013 00:32:30 +0000 Subject: [issue17145] memoryview(array.array) In-Reply-To: <1360170754.31.0.614797074916.issue17145@psf.upfronthosting.co.za> Message-ID: <1375403550.77.0.697244610446.issue17145@psf.upfronthosting.co.za> Demian Brecht added the comment: Bump. If the patch (or request) is invalid, might be worthwhile closing this issue (although I still think it's valid ;)). ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 03:12:20 2013 From: report at bugs.python.org (Guido van Rossum) Date: Fri, 02 Aug 2013 01:12:20 +0000 Subject: [issue18472] Update PEP 8 to encourage modern conventions In-Reply-To: <1373973528.84.0.159091610788.issue18472@psf.upfronthosting.co.za> Message-ID: <1375405940.66.0.319351095064.issue18472@psf.upfronthosting.co.za> Guido van Rossum added the comment: Patch applied. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 03:21:50 2013 From: report at bugs.python.org (Roundup Robot) Date: Fri, 02 Aug 2013 01:21:50 +0000 Subject: [issue17899] os.listdir() leaks FDs if invoked on FD pointing to a non-directory In-Reply-To: <1367608586.39.0.0815102318744.issue17899@psf.upfronthosting.co.za> Message-ID: <3c5rF94n90z7LkP@mail.python.org> Roundup Robot added the comment: New changeset e51cbc45f4ca by Larry Hastings in branch 'default': Issue #17899: Fix rare file descriptor leak in os.listdir(). http://hg.python.org/cpython/rev/e51cbc45f4ca ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 04:39:13 2013 From: report at bugs.python.org (Roundup Robot) Date: Fri, 02 Aug 2013 02:39:13 +0000 Subject: [issue17899] os.listdir() leaks FDs if invoked on FD pointing to a non-directory In-Reply-To: <1367608586.39.0.0815102318744.issue17899@psf.upfronthosting.co.za> Message-ID: <3c5syT22m2zQ7y@mail.python.org> Roundup Robot added the comment: New changeset bf68711bc939 by Larry Hastings in branch '3.3': Issue #17899: Fix rare file descriptor leak in os.listdir(). http://hg.python.org/cpython/rev/bf68711bc939 ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 04:39:59 2013 From: report at bugs.python.org (Larry Hastings) Date: Fri, 02 Aug 2013 02:39:59 +0000 Subject: [issue17899] os.listdir() leaks FDs if invoked on FD pointing to a non-directory In-Reply-To: <1367608586.39.0.0815102318744.issue17899@psf.upfronthosting.co.za> Message-ID: <1375411199.31.0.0628584984594.issue17899@psf.upfronthosting.co.za> Larry Hastings added the comment: Marking as closed/fixed. ---------- assignee: -> larry resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 05:12:40 2013 From: report at bugs.python.org (Nick Coghlan) Date: Fri, 02 Aug 2013 03:12:40 +0000 Subject: [issue18626] Make "python -m inspect " dump the source of a module Message-ID: <1375413160.45.0.218073630788.issue18626@psf.upfronthosting.co.za> New submission from Nick Coghlan: "python -m inspect " doesn't currently do anything. It would be handy if this: python -m inspect site Was roughly equivalent to: python -c "import inspect, site; print(inspect.getsource(site))" Even better would be if it understood entry point notation so you could use "modname:qualname" to get the source code of a particular item within a module. ---------- components: Library (Lib) messages: 194148 nosy: ncoghlan priority: normal severity: normal stage: needs patch status: open title: Make "python -m inspect " dump the source of a module type: enhancement versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 06:38:09 2013 From: report at bugs.python.org (Roundup Robot) Date: Fri, 02 Aug 2013 04:38:09 +0000 Subject: [issue17557] test_getgroups of test_posix can fail on OS X 10.8 if more than 16 groups In-Reply-To: <1364378141.47.0.183536890409.issue17557@psf.upfronthosting.co.za> Message-ID: <3c5wbh5MnBz7LjT@mail.python.org> Roundup Robot added the comment: New changeset 6d3b7e0559a0 by Ned Deily in branch '2.7': Issue #17557: Fix os.getgroups() to work with the modified behavior of http://hg.python.org/cpython/rev/6d3b7e0559a0 New changeset 0a4afa8833b5 by Ned Deily in branch '3.3': Issue #17557: Fix os.getgroups() to work with the modified behavior of http://hg.python.org/cpython/rev/0a4afa8833b5 New changeset 634a8e8816d4 by Ned Deily in branch 'default': Issue #17557: merge from 3.3 http://hg.python.org/cpython/rev/634a8e8816d4 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 06:43:31 2013 From: report at bugs.python.org (Ned Deily) Date: Fri, 02 Aug 2013 04:43:31 +0000 Subject: [issue17557] test_getgroups of test_posix can fail on OS X 10.8 if more than 16 groups In-Reply-To: <1364378141.47.0.183536890409.issue17557@psf.upfronthosting.co.za> Message-ID: <1375418611.85.0.118548824879.issue17557@psf.upfronthosting.co.za> Ned Deily added the comment: Committed patch (with slight modifications) for release in 2.7.6, 3.3.3, and 3.4.0. Thanks again, Mateusz. ---------- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed versions: -Python 3.2 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 06:43:38 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Fri, 02 Aug 2013 04:43:38 +0000 Subject: [issue18627] Typo in Modules/hashlib.h Message-ID: <1375418618.45.0.59595383081.issue18627@psf.upfronthosting.co.za> New submission from Vajrasky Kok: Got typo in Modules/hashlib.h. See this patch for detail: --- a/Modules/hashlib.h Wed Jul 31 20:48:26 2013 -0400 +++ b/Modules/hashlib.h Fri Aug 02 12:39:00 2013 +0800 @@ -2,7 +2,7 @@ /* * Given a PyObject* obj, fill in the Py_buffer* viewp with the result - * of PyObject_GetBuffer. Sets and exception and issues a return NULL + * of PyObject_GetBuffer. Sets an exception and issues a return NULL * on any errors. */ #define GET_BUFFER_VIEW_OR_ERROUT(obj, viewp) do { \ ---------- assignee: docs at python components: Documentation messages: 194151 nosy: docs at python, vajrasky priority: normal severity: normal status: open title: Typo in Modules/hashlib.h versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 06:49:44 2013 From: report at bugs.python.org (Terry J. Reedy) Date: Fri, 02 Aug 2013 04:49:44 +0000 Subject: [issue18628] PEP 8 and encodings Message-ID: <1375418984.87.0.318628832877.issue18628@psf.upfronthosting.co.za> New submission from Terry J. Reedy: Three related doc change proposals. The Versions only apply to the third as the first two are for PEP 8. 1. PEP 8 has a section entitled "Encodings (PEP 263)" with a link to the verbose PEP. I think it would be better if it were "Source Encoding" with a link to the 'current' Reference Manual section 2.1.4. Encoding declarations. The latter gets right to the point. 2. This section twice uses the informal and undefined term 'coding cookie'. It is not in the ref manual section above, nor in the glossary, nor in the index. (Dave Angel asked about the definition on python-list. Before searching on the web, he first thought it meant BOM.) I suggest changing "a coding cookie" to "an encoding declaration". 3. The index has several entries that begin with 'encode', including one that just says 'encodings'. The last is the one that points to 2.1.4., but one would only guess by process of elimination. I think 'encoding (source file)' or 'encoding declarations (source file)' would be clearer. ---------- assignee: docs at python components: Documentation messages: 194152 nosy: docs at python, ncoghlan, terry.reedy priority: normal severity: normal stage: needs patch status: open title: PEP 8 and encodings versions: Python 2.7, Python 3.3, Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 06:53:11 2013 From: report at bugs.python.org (Eric Snow) Date: Fri, 02 Aug 2013 04:53:11 +0000 Subject: [issue18626] Make "python -m inspect " dump the source of a module In-Reply-To: <1375413160.45.0.218073630788.issue18626@psf.upfronthosting.co.za> Message-ID: <1375419191.08.0.571987948186.issue18626@psf.upfronthosting.co.za> Eric Snow added the comment: At the risk of unnecessary complication, there is also other information that could be output, depending on the referenced object (module vs. class/func via qualname). For instance, a module's __file__ would be handy. So, the output could have a "header" with the relevant info, followed by a blank line, and then the source code. I suppose something like that could be added later with a commandline option, like "python -m inspect --info site", rather than being default behavior. Then this issue can stay focused on the simpler idea. :) Regardless, your proposal sounds good to me. I don't see any other meaningful use for "-m inspect". ---------- nosy: +eric.snow _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 07:13:54 2013 From: report at bugs.python.org (Roundup Robot) Date: Fri, 02 Aug 2013 05:13:54 +0000 Subject: [issue18627] Typo in Modules/hashlib.h In-Reply-To: <1375418618.45.0.59595383081.issue18627@psf.upfronthosting.co.za> Message-ID: <3c5xNx6Tc7z7LjT@mail.python.org> Roundup Robot added the comment: New changeset 3716d64f846b by Ned Deily in branch '3.3': Issue #18627: Fix typo noticed by Vajrasky Kok. http://hg.python.org/cpython/rev/3716d64f846b New changeset 454e9db1c750 by Ned Deily in branch 'default': Closes #18627: merge from 3.3 http://hg.python.org/cpython/rev/454e9db1c750 ---------- nosy: +python-dev resolution: -> fixed stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 07:14:55 2013 From: report at bugs.python.org (Ned Deily) Date: Fri, 02 Aug 2013 05:14:55 +0000 Subject: [issue18627] Typo in Modules/hashlib.h In-Reply-To: <1375418618.45.0.59595383081.issue18627@psf.upfronthosting.co.za> Message-ID: <1375420495.54.0.707371648291.issue18627@psf.upfronthosting.co.za> Changes by Ned Deily : ---------- versions: +Python 3.3 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 07:51:19 2013 From: report at bugs.python.org (Ronald Oussoren) Date: Fri, 02 Aug 2013 05:51:19 +0000 Subject: [issue18550] internal_setblocking() doesn't check return value of fcntl() In-Reply-To: <1374694779.19.0.0902694218162.issue18550@psf.upfronthosting.co.za> Message-ID: <1375422679.04.0.630929896378.issue18550@psf.upfronthosting.co.za> Ronald Oussoren added the comment: It's a bit tedious, but not too bad. The attached patch appears to work, but needs review (especially for the Windows and VMS branches in internal_setblocking. This changes the return value of internal_setblocking, it was unconditionally 1 and is now -1 if the call fails and 0 otherwise. ---------- keywords: +needs review, patch nosy: +ronaldoussoren stage: needs patch -> patch review _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 07:55:55 2013 From: report at bugs.python.org (Valerie Lambert) Date: Fri, 02 Aug 2013 05:55:55 +0000 Subject: [issue4885] mmap enhancement request In-Reply-To: <1231445893.72.0.162990779773.issue4885@psf.upfronthosting.co.za> Message-ID: <1375422955.52.0.0724329124788.issue4885@psf.upfronthosting.co.za> Valerie Lambert added the comment: I've uploaded a patch to make mmap_obj support weakref. A test is included in the patch. ---------- keywords: +patch nosy: +lambertv Added file: http://bugs.python.org/file31115/issue-4885.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 08:54:03 2013 From: report at bugs.python.org (Roundup Robot) Date: Fri, 02 Aug 2013 06:54:03 +0000 Subject: [issue18517] "xxlimited" extension declared incorrectly in setup.py In-Reply-To: <1374393760.41.0.977042124577.issue18517@psf.upfronthosting.co.za> Message-ID: <3c5zcV4yQjz7LjV@mail.python.org> Roundup Robot added the comment: New changeset e5607874e8ff by Ned Deily in branch '3.3': Issue #18517: Move definition of "xxlimited" extension to detect_modules(). http://hg.python.org/cpython/rev/e5607874e8ff New changeset 1d832bc857e2 by Ned Deily in branch 'default': Issue #18517: merge from 3.3 http://hg.python.org/cpython/rev/1d832bc857e2 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 08:56:00 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Fri, 02 Aug 2013 06:56:00 +0000 Subject: [issue16945] rewrite CGIHTTPRequestHandler to always use subprocess In-Reply-To: <1358000083.64.0.0773347996342.issue16945@psf.upfronthosting.co.za> Message-ID: <1375426560.53.0.600896599241.issue16945@psf.upfronthosting.co.za> Charles-Fran?ois Natali added the comment: Marking #10496 as a dependency (since it could prevent Python from running with low level privileges). ---------- dependencies: +Python startup should not require passwd entry _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 09:05:03 2013 From: report at bugs.python.org (Ned Deily) Date: Fri, 02 Aug 2013 07:05:03 +0000 Subject: [issue18517] "xxlimited" extension declared incorrectly in setup.py In-Reply-To: <1374393760.41.0.977042124577.issue18517@psf.upfronthosting.co.za> Message-ID: <1375427103.6.0.226161344631.issue18517@psf.upfronthosting.co.za> Ned Deily added the comment: On further reflection, only building on a debug build partially defeats part of the reason for building xxlimited; the current setup.py skips building in the debug case. Perhaps another approach would be to comment out the build in setup.py and instead add a new test case that builds xxlimited, similar to how test_distutils builds xxmodule. In any case, I've applied the original patch for 3.3.3 and 3.4.0 and closing this issue. Feel free to reopen if anyone wants to pursue this further. ---------- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed versions: +Python 3.3 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 09:07:35 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Fri, 02 Aug 2013 07:07:35 +0000 Subject: [issue18418] Thread.isAlive() sometimes True after fork In-Reply-To: <1373408030.66.0.77258289483.issue18418@psf.upfronthosting.co.za> Message-ID: <1375427255.41.0.51637343076.issue18418@psf.upfronthosting.co.za> Charles-Fran?ois Natali added the comment: I've posted another review (not sure you receive notifications). ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 09:08:28 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Fri, 02 Aug 2013 07:08:28 +0000 Subject: [issue10496] Python startup should not require passwd entry In-Reply-To: <1290398281.89.0.568058332092.issue10496@psf.upfronthosting.co.za> Message-ID: <1375427308.82.0.0624143240035.issue10496@psf.upfronthosting.co.za> Changes by Charles-Fran?ois Natali : ---------- keywords: +needs review _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 10:02:27 2013 From: report at bugs.python.org (Roundup Robot) Date: Fri, 02 Aug 2013 08:02:27 +0000 Subject: [issue18325] test_kqueue fails in OpenBSD In-Reply-To: <1372452616.96.0.640334462237.issue18325@psf.upfronthosting.co.za> Message-ID: <3c617Q5tJcz7Llj@mail.python.org> Roundup Robot added the comment: New changeset 8205e72b5cfc by Charles-Fran?ois Natali in branch '2.7': Issue #18325: Fix a test_kqueue failure on OpenBSD: kevent's data and event http://hg.python.org/cpython/rev/8205e72b5cfc ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 10:22:55 2013 From: report at bugs.python.org (Roundup Robot) Date: Fri, 02 Aug 2013 08:22:55 +0000 Subject: [issue18325] test_kqueue fails in OpenBSD In-Reply-To: <1372452616.96.0.640334462237.issue18325@psf.upfronthosting.co.za> Message-ID: <3c61b303vXz7LkQ@mail.python.org> Roundup Robot added the comment: New changeset 78db41e4c6a9 by Charles-Fran?ois Natali in branch '3.3': Issue #18325: Fix a test_kqueue failure on OpenBSD: kevent's data and event http://hg.python.org/cpython/rev/78db41e4c6a9 New changeset 1287d4c9cd39 by Charles-Fran?ois Natali in branch 'default': Issue #18325: Fix a test_kqueue failure on OpenBSD: kevent's data and event http://hg.python.org/cpython/rev/1287d4c9cd39 ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 10:23:53 2013 From: report at bugs.python.org (Marc-Andre Lemburg) Date: Fri, 02 Aug 2013 08:23:53 +0000 Subject: [issue18625] ks_c-5601-1987 is used by microsoft when it really means cp949 In-Reply-To: <1375401244.03.0.758628896825.issue18625@psf.upfronthosting.co.za> Message-ID: <1375431833.93.0.815706556181.issue18625@psf.upfronthosting.co.za> Marc-Andre Lemburg added the comment: The alias was added by Hye-Shik Chang: http://hg.python.org/cpython-fullhistory/annotate/887ce39f95f2/Lib/encodings/aliases.py#198 I've added him to the nosy list. If the alias don't match, we'd have to add a codec for the mismatching encoding to maintain compatibility (provided the mismatching encoding is still in use). ---------- nosy: +hyeshik.chang, lemburg _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 10:30:36 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Fri, 02 Aug 2013 08:30:36 +0000 Subject: [issue1611154] os.path.exists("file/") failure on Solaris 9 Message-ID: <1375432236.35.0.213394956079.issue1611154@psf.upfronthosting.co.za> Changes by Charles-Fran?ois Natali : ---------- status: open -> pending _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 10:34:06 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Fri, 02 Aug 2013 08:34:06 +0000 Subject: [issue17070] PEP 433: Use the new cloexec to improve security and avoid bugs In-Reply-To: <1359464957.74.0.458887600287.issue17070@psf.upfronthosting.co.za> Message-ID: <1375432446.52.0.46740016055.issue17070@psf.upfronthosting.co.za> Charles-Fran?ois Natali added the comment: Time to close this one, since the PEP has been superseeded by PEP 446? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 10:37:18 2013 From: report at bugs.python.org (Marc-Andre Lemburg) Date: Fri, 02 Aug 2013 08:37:18 +0000 Subject: [issue18624] Add alias for iso-8859-8-i which is the same as iso-8859-8 In-Reply-To: <1375398269.06.0.0330535739148.issue18624@psf.upfronthosting.co.za> Message-ID: <1375432638.63.0.125195794096.issue18624@psf.upfronthosting.co.za> Marc-Andre Lemburg added the comment: Here's a usable reference: http://www.w3.org/TR/html4/struct/dirlang.html#bidi88598 +1 on adding the alias. Also see http://lists.gnu.org/archive/html/lynx-dev/2012-02/msg00041.html for how Lynx does this. The URL also mentions "iso-8859-8-e", which should probably also be aliased to "iso-8859-8". Both names only apply to visual display characteristics of the text; the encoding is the same. ---------- nosy: +lemburg _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 10:57:03 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Fri, 02 Aug 2013 08:57:03 +0000 Subject: [issue11757] test_subprocess.test_communicate_timeout_large_ouput failure on select(): negative timeout? In-Reply-To: <1301869705.52.0.173979620005.issue11757@psf.upfronthosting.co.za> Message-ID: <1375433823.19.0.647717593817.issue11757@psf.upfronthosting.co.za> Changes by Charles-Fran?ois Natali : ---------- status: pending -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 10:59:19 2013 From: report at bugs.python.org (Michael Foord) Date: Fri, 02 Aug 2013 08:59:19 +0000 Subject: [issue18622] reset_mock on mock created by mock_open causes infinite recursion In-Reply-To: <1375391057.28.0.108463427813.issue18622@psf.upfronthosting.co.za> Message-ID: <1375433959.37.0.622075627105.issue18622@psf.upfronthosting.co.za> Michael Foord added the comment: The best way to solve this seems to be to track a set of visited ids (mocks we've reset) and not recurse into mocks we've already done. This is similar to the patch proposed on the google code issue - but not identical as that uses a list and has it as the default argument to reset_mock. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 10:59:35 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Fri, 02 Aug 2013 08:59:35 +0000 Subject: [issue12999] _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED usage on Solaris In-Reply-To: <1316244012.97.0.109004277803.issue12999@psf.upfronthosting.co.za> Message-ID: <1375433975.12.0.843459390404.issue12999@psf.upfronthosting.co.za> Charles-Fran?ois Natali added the comment: OK, let's close then. We can still re-open if this pops up again. ---------- status: pending -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 11:14:29 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Fri, 02 Aug 2013 09:14:29 +0000 Subject: [issue10897] UNIX mmap unnecessarily dup() file descriptor In-Reply-To: <1294845379.76.0.427887707002.issue10897@psf.upfronthosting.co.za> Message-ID: <1375434869.07.0.399202279328.issue10897@psf.upfronthosting.co.za> Charles-Fran?ois Natali added the comment: I changed my mind, and think we should keep the current behavior: it guarantees resize() won't break, and doesn't cost much. One extra FD per mmap is not a huge hit. If that's a problem, then the user can raise the RLIMIT_NOFILE. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 11:18:02 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Fri, 02 Aug 2013 09:18:02 +0000 Subject: [issue12588] test_capi.test_subinterps() failed on OpenBSD (powerpc) In-Reply-To: <1311111401.9.0.18298571301.issue12588@psf.upfronthosting.co.za> Message-ID: <1375435082.56.0.516887027886.issue12588@psf.upfronthosting.co.za> Changes by Charles-Fran?ois Natali : ---------- status: open -> pending _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 11:20:45 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Fri, 02 Aug 2013 09:20:45 +0000 Subject: [issue18325] test_kqueue fails in OpenBSD In-Reply-To: <1372452616.96.0.640334462237.issue18325@psf.upfronthosting.co.za> Message-ID: <1375435245.63.0.421771243036.issue18325@psf.upfronthosting.co.za> Charles-Fran?ois Natali added the comment: Should be fixed now. Thanks for the report, and sorry for the delay! ---------- resolution: -> fixed stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 11:24:05 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Fri, 02 Aug 2013 09:24:05 +0000 Subject: [issue16038] ftplib: unlimited readline() from connection In-Reply-To: <1348569175.14.0.867789583045.issue16038@psf.upfronthosting.co.za> Message-ID: <1375435445.7.0.250081619299.issue16038@psf.upfronthosting.co.za> Charles-Fran?ois Natali added the comment: So, what now? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 11:30:27 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Fri, 02 Aug 2013 09:30:27 +0000 Subject: [issue16635] Interpreter not closing stdout/stderr on exit In-Reply-To: <1354887230.33.0.111304282824.issue16635@psf.upfronthosting.co.za> Message-ID: <1375435827.5.0.261238693473.issue16635@psf.upfronthosting.co.za> Changes by Charles-Fran?ois Natali : ---------- resolution: -> rejected stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 11:42:30 2013 From: report at bugs.python.org (Nick Coghlan) Date: Fri, 02 Aug 2013 09:42:30 +0000 Subject: [issue18472] Update PEP 8 to encourage modern conventions In-Reply-To: <1375405940.66.0.319351095064.issue18472@psf.upfronthosting.co.za> Message-ID: Nick Coghlan added the comment: I like the new wording, but was there a missing "hg push" here? (Not seeing the update on hg.python.org/peps) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 11:56:46 2013 From: report at bugs.python.org (Lorenz Huedepohl) Date: Fri, 02 Aug 2013 09:56:46 +0000 Subject: [issue10897] UNIX mmap unnecessarily dup() file descriptor In-Reply-To: <1294845379.76.0.427887707002.issue10897@psf.upfronthosting.co.za> Message-ID: <1375437406.22.0.387314184319.issue10897@psf.upfronthosting.co.za> Lorenz Huedepohl added the comment: > If that's a problem, then the user can raise the RLIMIT_NOFILE. This can only be raised (above the hard limit) by a privileged process, so I would be out of luck there, as I could not convince my sysadmins to raise this further. Anyway, I don't really care anymore, I use my own, patched mmap module since I filed this bug. I don't quite understand why this module made an attempt to convert a simple mmap() to something more complex, with hidden state and resize() methods and whatnot :) - but it has been done, and I understand that you have to maintain backwards compatibility. Still, it would be nice if there was some way to get the result of a plain and simple mmap() as a buffer. Meanwhile, I will just use my own module, so feel free to close this if you feel like it :) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 12:20:55 2013 From: report at bugs.python.org (Nick Coghlan) Date: Fri, 02 Aug 2013 10:20:55 +0000 Subject: [issue18628] PEP 8 and encodings In-Reply-To: <1375418984.87.0.318628832877.issue18628@psf.upfronthosting.co.za> Message-ID: <1375438855.38.0.270553464584.issue18628@psf.upfronthosting.co.za> Changes by Nick Coghlan : ---------- assignee: docs at python -> ncoghlan _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 12:22:45 2013 From: report at bugs.python.org (Nick Coghlan) Date: Fri, 02 Aug 2013 10:22:45 +0000 Subject: [issue18472] Update PEP 8 to encourage modern conventions In-Reply-To: <1373973528.84.0.159091610788.issue18472@psf.upfronthosting.co.za> Message-ID: <1375438965.04.0.428693984675.issue18472@psf.upfronthosting.co.za> Nick Coghlan added the comment: I applied Guido's update in http://hg.python.org/peps/rev/82e24ac40255 I'm not sure what happened with Guido's "Patch applied" above, but I wanted to include Terry's encoding fixes from #18628, so I figured it made sense to ensure this was included first. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 12:32:14 2013 From: report at bugs.python.org (Nick Coghlan) Date: Fri, 02 Aug 2013 10:32:14 +0000 Subject: [issue18628] Better index entry for encoding declarations In-Reply-To: <1375418984.87.0.318628832877.issue18628@psf.upfronthosting.co.za> Message-ID: <1375439534.67.0.220882919968.issue18628@psf.upfronthosting.co.za> Nick Coghlan added the comment: I changed the section heading in PEP 8 to "Source File Encoding" and the sole remaining use of "a coding cookie" to "an encoding declaration". No link, since it would need separate links for Python 2 and 3, and that just gets messing. Now it uses the right terminology, it should be easier to look up. So, this is now just a regular docs bug for Terry's third point about the (lack of a suitable) index entry :) ---------- assignee: ncoghlan -> docs at python title: PEP 8 and encodings -> Better index entry for encoding declarations _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 14:49:29 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Fri, 02 Aug 2013 12:49:29 +0000 Subject: [issue4885] mmap enhancement request In-Reply-To: <1231445893.72.0.162990779773.issue4885@psf.upfronthosting.co.za> Message-ID: <1375447769.65.0.942478659206.issue4885@psf.upfronthosting.co.za> Changes by Antoine Pitrou : ---------- stage: needs patch -> patch review _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 15:33:34 2013 From: report at bugs.python.org (Christian Heimes) Date: Fri, 02 Aug 2013 13:33:34 +0000 Subject: [issue16499] CLI option for isolated mode In-Reply-To: <1353248771.63.0.703024605939.issue16499@psf.upfronthosting.co.za> Message-ID: <1375450414.35.0.926215216519.issue16499@psf.upfronthosting.co.za> Christian Heimes added the comment: Nick, you have deferred PEP 432 [1]. Do you mind if I check in the isolate mode for 3.4 and help you with PEP 432 for 3.5? [1] http://www.python.org/dev/peps/pep-0432/#pep-deferral ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 16:33:55 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Fri, 02 Aug 2013 14:33:55 +0000 Subject: [issue4885] mmap enhancement request In-Reply-To: <1231445893.72.0.162990779773.issue4885@psf.upfronthosting.co.za> Message-ID: <1375454035.97.0.330917067637.issue4885@psf.upfronthosting.co.za> Antoine Pitrou added the comment: Thanks Valerie. I've tested your patch and it looks good to me. Have you signed and sent a contributor's agreement? http://www.python.org/psf/contrib/ ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 16:37:42 2013 From: report at bugs.python.org (R. David Murray) Date: Fri, 02 Aug 2013 14:37:42 +0000 Subject: [issue18624] Add alias for iso-8859-8-i which is the same as iso-8859-8 In-Reply-To: <1375398269.06.0.0330535739148.issue18624@psf.upfronthosting.co.za> Message-ID: <1375454262.69.0.534466060897.issue18624@psf.upfronthosting.co.za> R. David Murray added the comment: I got the impression from what I read that -e included additional control sequences, but perhaps I misunderstood and that only meant that the data stream was expected to *use* additional control sequences but the control codes themselves are part of the base codec? I'm specifically thinking of this statement from the linked reference: "Because HTML uses the Unicode bidirectionality algorithm, conforming documents encoded using ISO 8859-8 must be labeled as "ISO-8859-8-i". Explicit directional control is also possible with HTML, but cannot be expressed with ISO 8859-8, so "ISO-8859-8-e" should not be used." The "cannot be expressed" seems to imply there are differences in the codec. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 17:14:16 2013 From: report at bugs.python.org (Guido van Rossum) Date: Fri, 02 Aug 2013 15:14:16 +0000 Subject: [issue18472] Update PEP 8 to encourage modern conventions In-Reply-To: <1373973528.84.0.159091610788.issue18472@psf.upfronthosting.co.za> Message-ID: <1375456456.17.0.0567419957463.issue18472@psf.upfronthosting.co.za> Guido van Rossum added the comment: Sorry, I forgot the push. I had to do a little merge dance and also fixed one typo (a redundant 'line') and now it's hopefully pushed. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 17:16:53 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Fri, 02 Aug 2013 15:16:53 +0000 Subject: [issue16853] add a Selector to the select module In-Reply-To: <1357234686.56.0.503079428281.issue16853@psf.upfronthosting.co.za> Message-ID: <1375456613.31.0.987002581332.issue16853@psf.upfronthosting.co.za> Charles-Fran?ois Natali added the comment: Here's a patch, based on the version in tulip's repo. I've added doc update and tests. I also made the following changes: - BaseSelector is an abstract base class (so one could imagine user code implementing its own selector on top of it) - SelectorKey is a named tuple: I think that's better than a class, because SelectorKeys can be returned to the user (register(), get_info(), etc), and we don't want him to mess with them. Also, we get a nice repr() for free - since SelectorKey is immutable, I added a get_keys() method, which returns all the keys registered. Since it's a dict values, the user can't mess with it This get_keys() method superseedes the registered_count() method, which can be simply replaced with len(selector.get_keys()). We could probably remove it? It also sort of superseedes the get_info() method: I don't remember, why was it needed? Would it be possible to get it into 3.4? ---------- keywords: +needs review Added file: http://bugs.python.org/file31116/selector-9.diff _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 17:16:54 2013 From: report at bugs.python.org (Nick Coghlan) Date: Fri, 02 Aug 2013 15:16:54 +0000 Subject: [issue16499] CLI option for isolated mode In-Reply-To: <1353248771.63.0.703024605939.issue16499@psf.upfronthosting.co.za> Message-ID: <1375456614.6.0.834151435495.issue16499@psf.upfronthosting.co.za> Nick Coghlan added the comment: Yep, sounds good to me ("don't wait for PEP 432" is what I meant to imply above, but I wasn't very clear about it) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 17:22:11 2013 From: report at bugs.python.org (Jean-Paul Calderone) Date: Fri, 02 Aug 2013 15:22:11 +0000 Subject: [issue18629] future division breaks timedelta division by integer Message-ID: <1375456931.04.0.558889166858.issue18629@psf.upfronthosting.co.za> New submission from Jean-Paul Calderone: datetime.timedelta instances are divisible by integers on Python 2.7, but not when __future__.division has been turned on: exarkun at top:~$ ~/Projects/cpython/2.7/python -c ' from datetime import timedelta print timedelta(seconds=3) / 2 ' 0:00:01.500000 exarkun at top:~$ ~/Projects/cpython/2.7/python -c ' from __future__ import division from datetime import timedelta print timedelta(seconds=3) / 2 ' Traceback (most recent call last): File "", line 4, in TypeError: unsupported operand type(s) for /: 'datetime.timedelta' and 'int' exarkun at top:~$ ~/Projects/cpython/2.7/python Python 2.7.5+ (2.7:8205e72b5cfc, Aug 2 2013, 11:12:04) This presents a minor barrier to Python 3 transitions, since it prevents the use of __future__.division in a module trying to retain Python 2 compatibility where timedelta division is used. ---------- components: Library (Lib) messages: 194181 nosy: exarkun priority: normal severity: normal status: open title: future division breaks timedelta division by integer type: behavior versions: Python 2.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 18:16:14 2013 From: report at bugs.python.org (Guido van Rossum) Date: Fri, 02 Aug 2013 16:16:14 +0000 Subject: [issue16853] add a Selector to the select module In-Reply-To: <1357234686.56.0.503079428281.issue16853@psf.upfronthosting.co.za> Message-ID: <1375460174.15.0.394950893193.issue16853@psf.upfronthosting.co.za> Guido van Rossum added the comment: Thanks! We should make sure this makes it into alpha 2. Could you also prepare a patch for Tulip itself? That way I can make sure Tulip works with either its own or the stdlib implementation. One thought: would it be better if the selectors ended up in a separate module rather than extending 'select'? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 18:21:16 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Fri, 02 Aug 2013 16:21:16 +0000 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375456931.04.0.558889166858.issue18629@psf.upfronthosting.co.za> Message-ID: <1375460476.41.0.86686348873.issue18629@psf.upfronthosting.co.za> Antoine Pitrou added the comment: You're just looking for floor division: $ python -Qnew Python 2.7.4 (default, Apr 19 2013, 18:28:01) [GCC 4.7.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 1/2 0.5 >>> from datetime import timedelta >>> print timedelta(seconds=3) // 2 0:00:01.500000 ---------- nosy: +pitrou _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 18:22:38 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Fri, 02 Aug 2013 16:22:38 +0000 Subject: [issue16853] add a Selector to the select module In-Reply-To: <1375460174.15.0.394950893193.issue16853@psf.upfronthosting.co.za> Message-ID: <1722601135.39249419.1375460552816.JavaMail.root@zimbra10-e2.priv.proxad.net> Antoine Pitrou added the comment: > One thought: would it be better if the selectors ended up in a > separate module rather than extending 'select'? IMHO they're fine in select. It's quite the natural place for them. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 18:27:12 2013 From: report at bugs.python.org (David Edelsohn) Date: Fri, 02 Aug 2013 16:27:12 +0000 Subject: [issue18609] test_ctypes failure on AIX in PyEval_CallObjectWithKeywords In-Reply-To: <1375305877.13.0.891928742401.issue18609@psf.upfronthosting.co.za> Message-ID: <1375460832.2.0.901336475477.issue18609@psf.upfronthosting.co.za> David Edelsohn added the comment: Thanks. The patch seems to return the tests to the expected failures and Python does not crash. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 19:05:15 2013 From: report at bugs.python.org (Jean-Paul Calderone) Date: Fri, 02 Aug 2013 17:05:15 +0000 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375456931.04.0.558889166858.issue18629@psf.upfronthosting.co.za> Message-ID: <1375463115.11.0.701437280093.issue18629@psf.upfronthosting.co.za> Jean-Paul Calderone added the comment: Hm. Maybe I am. Yet isn't true division implemented for this pair of types in Python 3? I'm not sure why it shouldn't be implemented for them in Python 2. Also that raises another question. Does a result of one and one half seconds make sense as the result of a floor division operation? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 19:12:04 2013 From: report at bugs.python.org (Steven D'Aprano) Date: Fri, 02 Aug 2013 17:12:04 +0000 Subject: [issue18585] Add a text truncation function In-Reply-To: <1375102150.65.0.445691594018.issue18585@psf.upfronthosting.co.za> Message-ID: <1375463524.89.0.156546355607.issue18585@psf.upfronthosting.co.za> Steven D'Aprano added the comment: A function like this often gets called to truncate lots of lines. Unfortunately for many use-cases, the part truncated is the most significant part of the line. E.g.: Scanning file: /home/fred/documents/datafil... /home/fred/documents/datafil... /home/fred/documents/datafil... /home/fred/documents/datafil... It's often better in cases like this to truncate in the middle: Scanning file: /home/fred/doc...datafile01.txt /home/fred/doc...datafile02.txt /home/fred/doc...datafile03.txt /home/fred/doc...datafile04.txt (I believe Mac OS-X routinely truncates long lines in the middle in this way.) Perhaps there could be an argument controlling where to truncate (left, right or centre). A good use-case for the new Enums, perhaps? :-) ---------- nosy: +stevenjd _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 19:19:04 2013 From: report at bugs.python.org (Steven D'Aprano) Date: Fri, 02 Aug 2013 17:19:04 +0000 Subject: [issue18585] Add a text truncation function In-Reply-To: <1375102150.65.0.445691594018.issue18585@psf.upfronthosting.co.za> Message-ID: <1375463944.76.0.282905026356.issue18585@psf.upfronthosting.co.za> Steven D'Aprano added the comment: Bike-shedding here... why "(...)"? Is it common to use round brackets for this purpose? In English-speaking countries, it is usual to use square brackets for editorial comments, including ellipsis "[...]". Either way, if you wanted to be more Unicode aware, you could save two characters by using \N{HORIZONTAL ELLIPSIS} "(?)" as the default. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 19:40:43 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Fri, 02 Aug 2013 17:40:43 +0000 Subject: [issue18585] Add a text truncation function In-Reply-To: <1375463944.76.0.282905026356.issue18585@psf.upfronthosting.co.za> Message-ID: <1375465235.2527.1.camel@fsol> Antoine Pitrou added the comment: > Bike-shedding here... why "(...)"? Is it common to use round brackets > for this purpose? In English-speaking countries, it is usual to use > square brackets for editorial comments, including ellipsis "[...]". Ah, really? French uses "[...]" but I thought English-speaking people, being different, used "(...)". So I'll change it. > Either way, if you wanted to be more Unicode aware, you could save two > characters by using \N{HORIZONTAL ELLIPSIS} "(?)" as the default. I'd rather stay on the ASCII side of things here. (also, the ellipsis character doesn't often look nice) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 19:46:22 2013 From: report at bugs.python.org (Tshepang Lekhonkhobe) Date: Fri, 02 Aug 2013 17:46:22 +0000 Subject: [issue18586] Allow running benchmarks for Python 3 from same directory In-Reply-To: <1375112281.72.0.724142875294.issue18586@psf.upfronthosting.co.za> Message-ID: <1375465582.69.0.759269308637.issue18586@psf.upfronthosting.co.za> Changes by Tshepang Lekhonkhobe : ---------- nosy: +tshepang _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 20:08:04 2013 From: report at bugs.python.org (Roumen Petrov) Date: Fri, 02 Aug 2013 18:08:04 +0000 Subject: [issue18630] mingw: exclude unix only modules Message-ID: <1375466884.41.0.796204643285.issue18630@psf.upfronthosting.co.za> New submission from Roumen Petrov: Split of issue3871 - build core modules. ---------- components: Build files: 0013-MINGW-exclude-unix-only-modules.patch keywords: patch messages: 194191 nosy: rpetrov priority: normal severity: normal status: open title: mingw: exclude unix only modules type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file31119/0013-MINGW-exclude-unix-only-modules.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 20:11:37 2013 From: report at bugs.python.org (Roumen Petrov) Date: Fri, 02 Aug 2013 18:11:37 +0000 Subject: [issue18631] mingw: setup msvcrt and _winapi modules Message-ID: <1375467097.24.0.168691156888.issue18631@psf.upfronthosting.co.za> New submission from Roumen Petrov: Split of issue3871 - build core modules. ---------- components: Build files: 0014-MINGW-setup-msvcrt-and-_winapi-modules.patch keywords: patch messages: 194192 nosy: rpetrov priority: normal severity: normal status: open title: mingw: setup msvcrt and _winapi modules type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file31120/0014-MINGW-setup-msvcrt-and-_winapi-modules.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 20:15:27 2013 From: report at bugs.python.org (Roumen Petrov) Date: Fri, 02 Aug 2013 18:15:27 +0000 Subject: [issue18632] mingw: build extensions with GCC Message-ID: <1375467327.02.0.323723692344.issue18632@psf.upfronthosting.co.za> New submission from Roumen Petrov: Split of issue3871 - build core modules. Now more simple version of previous patch. ---------- components: Build files: 0015-MINGW-build-extensions-with-GCC.patch keywords: patch messages: 194193 nosy: rpetrov priority: normal severity: normal status: open title: mingw: build extensions with GCC type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file31121/0015-MINGW-build-extensions-with-GCC.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 20:40:41 2013 From: report at bugs.python.org (Roundup Robot) Date: Fri, 02 Aug 2013 18:40:41 +0000 Subject: [issue10241] gc fixes for module m_copy attribute In-Reply-To: <1288410530.83.0.095379048444.issue10241@psf.upfronthosting.co.za> Message-ID: <3c6HHr2RdGzSY5@mail.python.org> Roundup Robot added the comment: New changeset 314a872f54e1 by Antoine Pitrou in branch 'default': Backout 62658d9d8926 (issue #10241): it causes a crash at shutdown when deallocating a Tkapp object. http://hg.python.org/cpython/rev/314a872f54e1 ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 20:42:08 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Fri, 02 Aug 2013 18:42:08 +0000 Subject: [issue10241] gc fixes for module m_copy attribute In-Reply-To: <1288410530.83.0.095379048444.issue10241@psf.upfronthosting.co.za> Message-ID: <1375468928.86.0.0430312533221.issue10241@psf.upfronthosting.co.za> Antoine Pitrou added the comment: I backed out the changeset in time for the Alpha 1 release. Further investigation should perhaps be made on the tkinter issue, but it's a bit cumbersome: you need a full test run in non-parallel mode to exhibit the segfault. ---------- stage: committed/rejected -> _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 20:44:22 2013 From: report at bugs.python.org (Roumen Petrov) Date: Fri, 02 Aug 2013 18:44:22 +0000 Subject: [issue18632] mingw: build extensions with GCC In-Reply-To: <1375467327.02.0.323723692344.issue18632@psf.upfronthosting.co.za> Message-ID: <1375469062.24.0.286283145019.issue18632@psf.upfronthosting.co.za> Changes by Roumen Petrov : Removed file: http://bugs.python.org/file31121/0015-MINGW-build-extensions-with-GCC.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 20:46:04 2013 From: report at bugs.python.org (Roumen Petrov) Date: Fri, 02 Aug 2013 18:46:04 +0000 Subject: [issue18632] mingw: build extensions with GCC In-Reply-To: <1375467327.02.0.323723692344.issue18632@psf.upfronthosting.co.za> Message-ID: <1375469164.31.0.589775176909.issue18632@psf.upfronthosting.co.za> Roumen Petrov added the comment: Attached up to date version of patch. ---------- Added file: http://bugs.python.org/file31122/0015-MINGW-build-extensions-with-GCC.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 20:55:02 2013 From: report at bugs.python.org (Roumen Petrov) Date: Fri, 02 Aug 2013 18:55:02 +0000 Subject: [issue18633] mingw: use Mingw32CCompiler as default compiler for mingw* build Message-ID: <1375469702.92.0.916914527806.issue18633@psf.upfronthosting.co.za> New submission from Roumen Petrov: Split of issue3871 - build core modules: improved version based on get_platform() ---------- components: Build, Cross-Build files: 0016-MINGW-use-Mingw32CCompiler-as-default-compiler-for-m.patch keywords: patch messages: 194197 nosy: rpetrov priority: normal severity: normal status: open title: mingw: use Mingw32CCompiler as default compiler for mingw* build type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file31123/0016-MINGW-use-Mingw32CCompiler-as-default-compiler-for-m.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 21:16:45 2013 From: report at bugs.python.org (Roumen Petrov) Date: Fri, 02 Aug 2013 19:16:45 +0000 Subject: [issue18634] mingw find import library Message-ID: <1375471005.24.0.423283634636.issue18634@psf.upfronthosting.co.za> New submission from Roumen Petrov: Split of issue3871 - build core modules: required by setup.py on hosts with installed only shared (DLL) packages. ---------- components: Build, Cross-Build files: 0017-MINGW-find-import-library.patch keywords: patch messages: 194198 nosy: rpetrov priority: normal severity: normal status: open title: mingw find import library type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file31124/0017-MINGW-find-import-library.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 21:34:16 2013 From: report at bugs.python.org (Chris Lambacher) Date: Fri, 02 Aug 2013 19:34:16 +0000 Subject: [issue18635] Enum sets _member_type_ to instantiated values but not the class Message-ID: <1375472056.62.0.564467694147.issue18635@psf.upfronthosting.co.za> New submission from Chris Lambacher: It would be useful to set the discovered member_type to the Enum class and not just the instance. Attached is a patch to add _member_type_ to the enum_class. ---------- files: enum_member_type_on_class.patch keywords: patch messages: 194199 nosy: lambacck priority: normal severity: normal status: open title: Enum sets _member_type_ to instantiated values but not the class type: behavior versions: Python 3.4 Added file: http://bugs.python.org/file31125/enum_member_type_on_class.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 21:35:16 2013 From: report at bugs.python.org (Roumen Petrov) Date: Fri, 02 Aug 2013 19:35:16 +0000 Subject: [issue18636] mingw: setup _ssl module Message-ID: <1375472116.92.0.328904140064.issue18636@psf.upfronthosting.co.za> New submission from Roumen Petrov: Split of issue3871 - build core modules. ---------- components: Build, Cross-Build, Extension Modules files: 0018-MINGW-setup-_ssl-module.patch keywords: patch messages: 194200 nosy: rpetrov priority: normal severity: normal status: open title: mingw: setup _ssl module type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file31126/0018-MINGW-setup-_ssl-module.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 21:38:29 2013 From: report at bugs.python.org (Roumen Petrov) Date: Fri, 02 Aug 2013 19:38:29 +0000 Subject: [issue18637] mingw: export _PyNode_SizeOf as PyAPI for parser module Message-ID: <1375472309.41.0.38535995821.issue18637@psf.upfronthosting.co.za> New submission from Roumen Petrov: Split of issue3871 - build core modules. ---------- components: Extension Modules, Interpreter Core files: 0019-MINGW-export-_PyNode_SizeOf-as-PyAPI-for-parser-modu.patch keywords: patch messages: 194201 nosy: rpetrov priority: normal severity: normal status: open title: mingw: export _PyNode_SizeOf as PyAPI for parser module type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file31127/0019-MINGW-export-_PyNode_SizeOf-as-PyAPI-for-parser-modu.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 21:42:01 2013 From: report at bugs.python.org (Roumen Petrov) Date: Fri, 02 Aug 2013 19:42:01 +0000 Subject: [issue18638] mingw: generalization of posix build in sysconfig.py Message-ID: <1375472521.36.0.980902141673.issue18638@psf.upfronthosting.co.za> New submission from Roumen Petrov: Split of issue3871 - build core modules: improved patch ---------- components: Build, Cross-Build files: 0020-MINGW-generalization-of-posix-build-in-sysconfig.py.patch keywords: patch messages: 194202 nosy: rpetrov priority: normal severity: normal status: open title: mingw: generalization of posix build in sysconfig.py versions: Python 3.4 Added file: http://bugs.python.org/file31128/0020-MINGW-generalization-of-posix-build-in-sysconfig.py.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 21:45:43 2013 From: report at bugs.python.org (Roumen Petrov) Date: Fri, 02 Aug 2013 19:45:43 +0000 Subject: [issue18639] mingw: avoid circular dependency from time module during native build of extentions Message-ID: <1375472743.5.0.167328971816.issue18639@psf.upfronthosting.co.za> New submission from Roumen Petrov: Split of issue3871 - build core modules: patch is not required in cross-build environment. ---------- assignee: eric.araujo components: Build, Distutils, Extension Modules files: 0021-MINGW-avoid-circular-dependency-from-time-module-dur.patch keywords: patch messages: 194203 nosy: eric.araujo, rpetrov, tarek priority: normal severity: normal status: open title: mingw: avoid circular dependency from time module during native build of extentions versions: Python 3.4 Added file: http://bugs.python.org/file31129/0021-MINGW-avoid-circular-dependency-from-time-module-dur.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 21:49:19 2013 From: report at bugs.python.org (Roumen Petrov) Date: Fri, 02 Aug 2013 19:49:19 +0000 Subject: [issue18640] mingw: generalization of posix build in distutils/sysconfig.py Message-ID: <1375472959.93.0.699092056169.issue18640@psf.upfronthosting.co.za> New submission from Roumen Petrov: Split of issue3871 - build core modules: improved patch ---------- assignee: eric.araujo components: Build, Cross-Build, Distutils, Extension Modules files: 0022-MINGW-generalization-of-posix-build-in-distutils-sys.patch keywords: patch messages: 194204 nosy: eric.araujo, rpetrov, tarek priority: normal severity: normal status: open title: mingw: generalization of posix build in distutils/sysconfig.py type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file31130/0022-MINGW-generalization-of-posix-build-in-distutils-sys.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 21:52:05 2013 From: report at bugs.python.org (Roumen Petrov) Date: Fri, 02 Aug 2013 19:52:05 +0000 Subject: [issue18641] mingw: customize site Message-ID: <1375473125.37.0.800889135942.issue18641@psf.upfronthosting.co.za> New submission from Roumen Petrov: Split of issue3871 - build core modules: improved patch ---------- components: Build, Cross-Build, Extension Modules files: 0023-MINGW-customize-site.patch keywords: patch messages: 194205 nosy: rpetrov priority: normal severity: normal status: open title: mingw: customize site type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file31131/0023-MINGW-customize-site.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 22:06:02 2013 From: report at bugs.python.org (Ethan Furman) Date: Fri, 02 Aug 2013 20:06:02 +0000 Subject: [issue18635] Enum sets _member_type_ to instantiated values but not the class In-Reply-To: <1375472056.62.0.564467694147.issue18635@psf.upfronthosting.co.za> Message-ID: <1375473962.43.0.203883077075.issue18635@psf.upfronthosting.co.za> Changes by Ethan Furman : ---------- assignee: -> ethan.furman nosy: +ethan.furman _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 22:13:50 2013 From: report at bugs.python.org (Ethan Furman) Date: Fri, 02 Aug 2013 20:13:50 +0000 Subject: [issue18635] Enum sets _member_type_ to instantiated values but not the class In-Reply-To: <1375472056.62.0.564467694147.issue18635@psf.upfronthosting.co.za> Message-ID: <1375474430.1.0.56528035515.issue18635@psf.upfronthosting.co.za> Ethan Furman added the comment: Ah, so the Enum class has the mixin class as wall as / instead of the Enum member (which should find it via normal attribute lookup). I have no problem with that. I'll need to make a couple more changes to the code, add a test, etc., etc. It won't make the first alpha, but should be ready for the second. ---------- nosy: +barry, eli.bendersky _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 19:59:46 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Fri, 02 Aug 2013 17:59:46 +0000 Subject: [issue16853] add a Selector to the select module In-Reply-To: <1375460174.15.0.394950893193.issue16853@psf.upfronthosting.co.za> Message-ID: Charles-Fran?ois Natali added the comment: > Thanks! We should make sure this makes it into alpha 2. Could you also > prepare a patch for Tulip itself? That way I can make sure Tulip works with > either its own or the stdlib implementation. Sure, here's a patch (tulip_selector_stdlib.diff). It seems to work fine, but I'm getting random errors even with vanilla tulip: """ ====================================================================== FAIL: test_run_until_complete_timeout (events_test.EPollEventLoopTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "tests/events_test.py", line 194, in test_run_until_complete_timeout self.assertTrue(0.009 <= t2-t1 <= 0.018, t2-t1) AssertionError: False is not true : 0.0055361779959639534 """ Looks like the timeouts check may be a bit too tight? I'm also updating the patch a bit: - when a timeout < 0 is passed to select(), it's treated as timeout == 0, i.e. polling. It fixes a common kind of nasty bugs in user code where when calculating timeouts, if you end up passing a negative value, it can either be interpreted as an infinite wait, or can raise EINVAL - previously, upon EINTR (InterruptedError), select() would return an empty list. That can be a problem if the user specified a timeout, because you end up returning too early. Thanks to a decorator, select() now retries upon EINTR, re-calculating the timeout. I also added a test for this. I'm pretty happy with the state now, so I think it's ready for review. There are a couple points I'd like more specific feedback: - is the registered_count() method still useful, now that get_keys() can return all the keys? - same thing for get_info(), it feels redundant - the documentation ;-) ---------- Added file: http://bugs.python.org/file31117/selector-11.diff Added file: http://bugs.python.org/file31118/tulip_selector_stdlib.diff _______________________________________ Python tracker _______________________________________ -------------- next part -------------- diff -r 1287d4c9cd39 Lib/select.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/select.py Fri Aug 02 19:45:03 2013 +0200 @@ -0,0 +1,435 @@ +"""Select module. + +This module supports asynchronous I/O on multiple file descriptors. +""" + + +from abc import ABCMeta, abstractmethod +from collections import namedtuple +import functools +from _select import * +import sys +try: + from time import monotonic as time +except ImportError: + from time import time as time + + +# generic events, that must be mapped to implementation-specific ones +EVENT_READ = (1 << 0) +EVENT_WRITE = (1 << 1) + + +def _fileobj_to_fd(fileobj): + """Return a file descriptor from a file object. + + Parameters: + fileobj -- file descriptor, or any object with a `fileno()` method + + Returns: + corresponding file descriptor + """ + if isinstance(fileobj, int): + fd = fileobj + else: + try: + fd = int(fileobj.fileno()) + except (ValueError, TypeError): + raise ValueError("Invalid file object: {!r}".format(fileobj)) + return fd + + +def _select_interrupt_wrapper(func): + """InterruptedError-safe wrapper for select(), taking the (optional) + timeout into account.""" + @functools.wraps(func) + def wrapper(self, timeout=None): + if timeout is not None and timeout > 0: + deadline = time() + timeout + while True: + try: + return func(self, timeout) + except InterruptedError: + if timeout is not None: + if timeout > 0: + timeout = deadline - time() + if timeout <= 0: + # timeout expired + return [] + + return wrapper + + +SelectorKey = namedtuple('SelectorKey', ['fileobj', 'fd', 'events', 'data']) +"""Object used internally to associate a file object to its backing file +descriptor, selected event mask and attached data.""" + + +class BaseSelector(metaclass=ABCMeta): + """Base selector class. + + A selector supports registering file objects to be monitored for specific + I/O events. + + A file object is a file descriptor or any object with a `fileno()` method. + An arbitrary object can be attached to the file object, which can be used + for example to store context information, a callback, etc. + + A selector can use various implementations (select(), poll(), epoll()...) + depending on the platform. The default `Selector` class uses the most + performant implementation on the current platform. + """ + + def __init__(self): + # this maps file descriptors to keys + self._fd_to_key = {} + # this maps file objects to keys - for fast (un)registering + self._fileobj_to_key = {} + + def register(self, fileobj, events, data=None): + """Register a file object. + + Parameters: + fileobj -- file object + events -- events to monitor (bitwise mask of EVENT_READ|EVENT_WRITE) + data -- attached data + + Returns: + SelectorKey instance + """ + if (not events) or (events & ~(EVENT_READ | EVENT_WRITE)): + raise ValueError("Invalid events: {}".format(events)) + + if fileobj in self._fileobj_to_key: + raise ValueError("{!r} is already registered".format(fileobj)) + + key = SelectorKey(fileobj, _fileobj_to_fd(fileobj), events, data) + self._fd_to_key[key.fd] = key + self._fileobj_to_key[fileobj] = key + return key + + def unregister(self, fileobj): + """Unregister a file object. + + Parameters: + fileobj -- file object + + Returns: + SelectorKey instance + """ + try: + key = self._fileobj_to_key[fileobj] + del self._fd_to_key[key.fd] + del self._fileobj_to_key[fileobj] + except KeyError: + raise ValueError("{!r} is not registered".format(fileobj)) + return key + + def modify(self, fileobj, events, data=None): + """Change a registered file object monitored events or attached data. + + Parameters: + fileobj -- file object + events -- events to monitor (bitwise mask of EVENT_READ|EVENT_WRITE) + data -- attached data + """ + # TODO: Subclasses can probably optimize this even further. + try: + key = self._fileobj_to_key[fileobj] + except KeyError: + raise ValueError("{!r} is not registered".format(fileobj)) + if events != key.events or data != key.data: + # TODO: If only the data changed, use a shortcut that only + # updates the data. + self.unregister(fileobj) + return self.register(fileobj, events, data) + else: + return key + + @abstractmethod + def select(self, timeout=None): + """Perform the actual selection, until some monitored file objects are + ready or a timeout expires. + + Parameters: + timeout -- if timeout > 0, this specifies the maximum wait time, in + seconds + if timeout <= 0, the select() call won't block, and will + report the currently ready file objects + if timeout is None, select() will block until a monitored + file object becomes ready + + Returns: + list of (fileobj, events, attached data) for ready file objects + `events` is a bitwise mask of EVENT_READ|EVENT_WRITE + """ + raise NotImplementedError() + + def close(self): + """Close the selector. + + This must be called to make sure that any underlying resource is freed. + """ + self._fd_to_key.clear() + self._fileobj_to_key.clear() + + def get_keys(self): + """Return the set of SelectorKey for all the file objects + registered.""" + return self._fd_to_key.values() + + def get_info(self, fileobj): + """Return information about a registered file object. + + Returns: + (events, data) associated to this file object + + Raises KeyError if the file object is not registered. + """ + try: + key = self._fileobj_to_key[fileobj] + except KeyError: + raise KeyError("{} is not registered".format(fileobj)) + return key.events, key.data + + def registered_count(self): + """Return the number of registered file objects. + + Returns: + number of currently registered file objects + """ + return len(self.get_keys()) + + def __enter__(self): + return self + + def __exit__(self, *args): + self.close() + + def _key_from_fd(self, fd): + """Return the key associated to a given file descriptor. + + Parameters: + fd -- file descriptor + + Returns: + corresponding key, or None if not found + """ + try: + return self._fd_to_key[fd] + except KeyError: + return None + + +class SelectSelector(BaseSelector): + """Select-based selector.""" + + def __init__(self): + super().__init__() + self._readers = set() + self._writers = set() + + def register(self, fileobj, events, data=None): + key = super().register(fileobj, events, data) + if events & EVENT_READ: + self._readers.add(key.fd) + if events & EVENT_WRITE: + self._writers.add(key.fd) + return key + + def unregister(self, fileobj): + key = super().unregister(fileobj) + self._readers.discard(key.fd) + self._writers.discard(key.fd) + return key + + @_select_interrupt_wrapper + def select(self, timeout=None): + timeout = None if timeout is None else max(timeout, 0) + r, w, _ = self._select(self._readers, self._writers, [], timeout) + r = set(r) + w = set(w) + ready = [] + for fd in r | w: + events = 0 + if fd in r: + events |= EVENT_READ + if fd in w: + events |= EVENT_WRITE + + key = self._key_from_fd(fd) + if key: + ready.append((key.fileobj, events & key.events, key.data)) + return ready + + if sys.platform == 'win32': + def _select(self, r, w, _, timeout=None): + r, w, x = select(r, w, w, timeout) + return r, w + x, [] + else: + from _select import select as _select + + +if 'poll' in globals(): + + # TODO: Implement poll() for Windows with workaround for + # brokenness in WSAPoll() (Richard Oudkerk, see + # http://bugs.python.org/issue16507). + + class PollSelector(BaseSelector): + """Poll-based selector.""" + + def __init__(self): + super().__init__() + self._poll = poll() + + def register(self, fileobj, events, data=None): + key = super().register(fileobj, events, data) + poll_events = 0 + if events & EVENT_READ: + poll_events |= POLLIN + if events & EVENT_WRITE: + poll_events |= POLLOUT + self._poll.register(key.fd, poll_events) + return key + + def unregister(self, fileobj): + key = super().unregister(fileobj) + self._poll.unregister(key.fd) + return key + + @_select_interrupt_wrapper + def select(self, timeout=None): + timeout = None if timeout is None else max(int(1000 * timeout), 0) + ready = [] + fd_event_list = self._poll.poll(timeout) + for fd, event in fd_event_list: + events = 0 + if event & ~POLLIN: + events |= EVENT_WRITE + if event & ~POLLOUT: + events |= EVENT_READ + + key = self._key_from_fd(fd) + if key: + ready.append((key.fileobj, events & key.events, key.data)) + return ready + + +if 'epoll' in globals(): + + class EpollSelector(BaseSelector): + """Epoll-based selector.""" + + def __init__(self): + super().__init__() + self._epoll = epoll() + + def fileno(self): + return self._epoll.fileno() + + def register(self, fileobj, events, data=None): + key = super().register(fileobj, events, data) + epoll_events = 0 + if events & EVENT_READ: + epoll_events |= EPOLLIN + if events & EVENT_WRITE: + epoll_events |= EPOLLOUT + self._epoll.register(key.fd, epoll_events) + return key + + def unregister(self, fileobj): + key = super().unregister(fileobj) + self._epoll.unregister(key.fd) + return key + + @_select_interrupt_wrapper + def select(self, timeout=None): + timeout = -1 if timeout is None else max(timeout, 0) + max_ev = len(self.get_keys()) + ready = [] + fd_event_list = self._epoll.poll(timeout, max_ev) + for fd, event in fd_event_list: + events = 0 + if event & ~EPOLLIN: + events |= EVENT_WRITE + if event & ~EPOLLOUT: + events |= EVENT_READ + + key = self._key_from_fd(fd) + if key: + ready.append((key.fileobj, events & key.events, key.data)) + return ready + + def close(self): + super().close() + self._epoll.close() + + +if 'kqueue' in globals(): + + class KqueueSelector(BaseSelector): + """Kqueue-based selector.""" + + def __init__(self): + super().__init__() + self._kqueue = kqueue() + + def fileno(self): + return self._kqueue.fileno() + + def unregister(self, fileobj): + key = super().unregister(fileobj) + if key.events & EVENT_READ: + kev = kevent(key.fd, KQ_FILTER_READ, KQ_EV_DELETE) + self._kqueue.control([kev], 0, 0) + if key.events & EVENT_WRITE: + kev = kevent(key.fd, KQ_FILTER_WRITE, KQ_EV_DELETE) + self._kqueue.control([kev], 0, 0) + return key + + def register(self, fileobj, events, data=None): + key = super().register(fileobj, events, data) + if events & EVENT_READ: + kev = kevent(key.fd, KQ_FILTER_READ, KQ_EV_ADD) + self._kqueue.control([kev], 0, 0) + if events & EVENT_WRITE: + kev = kevent(key.fd, KQ_FILTER_WRITE, KQ_EV_ADD) + self._kqueue.control([kev], 0, 0) + return key + + @_select_interrupt_wrapper + def select(self, timeout=None): + timeout = None if timeout is None else max(timeout, 0) + max_ev = len(self.get_keys()) + ready = [] + kev_list = self._kqueue.control(None, max_ev, timeout) + for kev in kev_list: + fd = kev.ident + flag = kev.filter + events = 0 + if flag == KQ_FILTER_READ: + events |= EVENT_READ + if flag == KQ_FILTER_WRITE: + events |= EVENT_WRITE + + key = self._key_from_fd(fd) + if key: + ready.append((key.fileobj, events & key.events, key.data)) + return ready + + def close(self): + super().close() + self._kqueue.close() + + +# Choose the best implementation: roughly, epoll|kqueue > poll > select. +# select() also can't accept a FD > FD_SETSIZE (usually around 1024) +if 'KqueueSelector' in globals(): + DefaultSelector = KqueueSelector +elif 'EpollSelector' in globals(): + DefaultSelector = EpollSelector +elif 'PollSelector' in globals(): + DefaultSelector = PollSelector +else: + DefaultSelector = SelectSelector diff -r 1287d4c9cd39 Lib/test/test_select.py --- a/Lib/test/test_select.py Fri Aug 02 10:22:07 2013 +0200 +++ b/Lib/test/test_select.py Fri Aug 02 19:45:03 2013 +0200 @@ -1,9 +1,28 @@ import errno import os +import random import select +import signal import sys import unittest from test import support +try: + from time import monotonic as time +except ImportError: + from time import time as time +try: + import resource +except ImportError: + resource = None + + +def find_ready_matching(ready, flag): + match = [] + for fd, mode, data in ready: + if mode & flag: + match.append(fd) + return match + @unittest.skipIf((sys.platform[:3]=='win'), "can't easily test on this system") @@ -75,9 +94,379 @@ a[:] = [F()] * 10 self.assertEqual(select.select([], a, []), ([], a[:5], [])) + +class BaseSelectorTestCase(unittest.TestCase): + + def test_register(self): + s = self.SELECTOR() + self.addCleanup(s.close) + + rd, wr = os.pipe() + self.addCleanup(os.close, rd) + self.addCleanup(os.close, wr) + rdo = os.fdopen(rd, "rb", closefd=False) + + key = s.register(rdo, select.EVENT_READ, "data") + self.assertIsInstance(key, select.SelectorKey) + self.assertEqual(key.fileobj, rdo) + self.assertEqual(key.fd, rd) + self.assertEqual(key.data, "data") + + # register an unknown event + self.assertRaises(ValueError, s.register, 0, 999999) + + # register twice + self.assertRaises(ValueError, s.register, rdo, select.EVENT_READ) + + def test_unregister(self): + s = self.SELECTOR() + self.addCleanup(s.close) + + rd, wr = os.pipe() + self.addCleanup(os.close, rd) + self.addCleanup(os.close, wr) + + s.register(rd, select.EVENT_READ) + s.unregister(rd) + self.assertFalse(s.get_keys()) + + # unregister an unknown file obj + self.assertRaises(ValueError, s.unregister, 999999) + + # unregister twice + self.assertRaises(ValueError, s.unregister, rd) + + def test_modify(self): + s = self.SELECTOR() + self.addCleanup(s.close) + + rd, wr = os.pipe() + self.addCleanup(os.close, rd) + self.addCleanup(os.close, wr) + + key = s.register(rd, select.EVENT_READ) + + # modify events + key2 = s.modify(rd, select.EVENT_WRITE) + self.assertNotEqual(key.events, key2.events) + self.assertEqual((select.EVENT_WRITE, None), s.get_info(rd)) + + s.unregister(rd) + + # modify data + d1 = object() + d2 = object() + + key = s.register(rd, select.EVENT_READ, d1) + key2 = s.modify(rd, select.EVENT_READ, d2) + self.assertEqual(key.events, key2.events) + self.assertNotEqual(key.data, key2.data) + self.assertEqual((select.EVENT_READ, d2), s.get_info(rd)) + + # modify unknown file obj + self.assertRaises(ValueError, s.modify, 999999, select.EVENT_READ) + + def test_close(self): + s = self.SELECTOR() + self.addCleanup(s.close) + + rd, wr = os.pipe() + self.addCleanup(os.close, rd) + self.addCleanup(os.close, wr) + + s.register(rd, select.EVENT_READ) + s.register(wr, select.EVENT_WRITE) + + s.close() + self.assertFalse(s.get_keys()) + + def test_get_keys(self): + s = self.SELECTOR() + self.addCleanup(s.close) + + rd, wr = os.pipe() + self.addCleanup(os.close, rd) + self.addCleanup(os.close, wr) + rdo = os.fdopen(rd, "rb", closefd=False) + wro = os.fdopen(wr, "wb", closefd=False) + + s.register(rdo, select.EVENT_READ, "rdo") + s.register(wro, select.EVENT_WRITE, "wro") + + self.assertEqual(set(s.get_keys()), + set([select.SelectorKey(rdo, rd, select.EVENT_READ, "rdo"), + select.SelectorKey(wro, wr, select.EVENT_WRITE, "wro")])) + + s.close() + self.assertFalse(s.get_keys()) + + def test_get_info(self): + s = self.SELECTOR() + self.addCleanup(s.close) + + rd, wr = os.pipe() + self.addCleanup(os.close, rd) + self.addCleanup(os.close, wr) + + s.register(rd, select.EVENT_READ, "data") + self.assertEqual((select.EVENT_READ, "data"), s.get_info(rd)) + + # unknown file obj + self.assertRaises(KeyError, s.get_info, 999999) + + def test_registered_count(self): + s = self.SELECTOR() + self.addCleanup(s.close) + + rd, wr = os.pipe() + self.addCleanup(os.close, rd) + self.addCleanup(os.close, wr) + + self.assertEqual(0, s.registered_count()) + + s.register(rd, select.EVENT_READ) + s.register(wr, select.EVENT_WRITE) + self.assertEqual(2, s.registered_count()) + + s.unregister(rd) + s.unregister(wr) + self.assertEqual(0, s.registered_count()) + + def test_context_manager(self): + s = self.SELECTOR() + self.addCleanup(s.close) + + rd, wr = os.pipe() + self.addCleanup(os.close, rd) + self.addCleanup(os.close, wr) + + with s as sel: + sel.register(rd, select.EVENT_READ) + sel.register(wr, select.EVENT_WRITE) + + self.assertFalse(s.get_keys()) + + @unittest.skipUnless(hasattr(select.DefaultSelector, 'fileno'), + 'test needs DefaultSelector.fileno()') + def test_fileno(self): + self.assertIsInstance(select.DefaultSelector().fileno(), int) + + def test_selector(self): + s = self.SELECTOR() + self.addCleanup(s.close) + + NUM_PIPES = 12 + MSG = b" This is a test." + MSG_LEN = len(MSG) + readers = [] + writers = [] + r2w = {} + w2r = {} + + for i in range(NUM_PIPES): + rd, wr = os.pipe() + s.register(rd, select.EVENT_READ) + s.register(wr, select.EVENT_WRITE) + readers.append(rd) + writers.append(wr) + r2w[rd] = wr + w2r[wr] = rd + + bufs = [] + + while writers: + ready = s.select() + ready_writers = find_ready_matching(ready, select.EVENT_WRITE) + if not ready_writers: + self.fail("no pipes ready for writing") + wr = random.choice(ready_writers) + os.write(wr, MSG) + + ready = s.select() + ready_readers = find_ready_matching(ready, select.EVENT_READ) + if not ready_readers: + self.fail("no pipes ready for reading") + self.assertEqual([w2r[wr]], ready_readers) + rd = ready_readers[0] + buf = os.read(rd, MSG_LEN) + self.assertEqual(len(buf), MSG_LEN) + bufs.append(buf) + os.close(r2w[rd]) ; os.close(rd) + s.unregister(r2w[rd]) + s.unregister(rd) + writers.remove(r2w[rd]) + + self.assertEqual(bufs, [MSG] * NUM_PIPES) + + def test_multi_timeout(self): + s = self.SELECTOR() + self.addCleanup(s.close) + + cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done' + p = os.popen(cmd, 'r') + s.register(p.fileno(), select.EVENT_READ, p) + + for tout in (0, 1, 2, 4, 8, 16) + (None,)*10: + if support.verbose: + print('timeout =', tout) + + ready = s.select(tout) + if not ready: + continue + eof_seen = False + for fileobj, evt, data in ready: + if fileobj == p.fileno() and evt & select.EVENT_READ: + while True: + line = p.readline() + if support.verbose: + print(repr(line)) + if not line: + if support.verbose: + print('EOF') + eof_seen = True + break + if not eof_seen: + self.fail('Unexpected return values from select(): %r' % ready) + p.close() + + def test_below_fd_setsize(self): + # No implementation should have a problem with less than FD_SETSIZE + # file descriptors. To be conservative, let's say 64. + NUM_FDS = 64 + + s = self.SELECTOR() + self.addCleanup(s.close) + + r, w = os.pipe() + self.addCleanup(os.close, r) + self.addCleanup(os.close, w) + + for i in range(NUM_FDS): + fd = os.dup(w) + self.addCleanup(os.close, fd) + + s.register(fd, select.EVENT_WRITE) + self.assertEquals(NUM_FDS, len(s.select())) + + def test_timeout(self): + s = self.SELECTOR() + self.addCleanup(s.close) + + rd, wr = os.pipe() + self.addCleanup(os.close, rd) + self.addCleanup(os.close, wr) + + s.register(wr, select.EVENT_WRITE) + self.assertEqual(1, len(s.select(0))) + self.assertEqual(1, len(s.select(-1))) + + s.unregister(wr) + s.register(rd, select.EVENT_READ) + self.assertEqual(0, len(s.select(0))) + self.assertEqual(0, len(s.select(-1))) + + @unittest.skipUnless(hasattr(signal, "alarm"), + "signal.alarm() required for this test") + def test_interrupted(self): + s = self.SELECTOR() + self.addCleanup(s.close) + + rd, wr = os.pipe() + self.addCleanup(os.close, rd) + self.addCleanup(os.close, wr) + + orig_alrm_handler = signal.signal(signal.SIGALRM, lambda *args: None) + self.addCleanup(signal.alarm, 0) + self.addCleanup(signal.signal, signal.SIGALRM, orig_alrm_handler) + + signal.alarm(1) + + s.register(rd, select.EVENT_READ) + t = time() + self.assertEqual([], s.select(2)) + self.assertTrue(1.7 < time() - t < 3) + + +class ScalableSelectorMixIn: + + @unittest.skipUnless(resource, "Test needs resource module") + def test_above_fd_setsize(self): + # A scalable implementation should have no problem with more than + # FD_SETSIZE file descriptors. Since we don't know the value, we just + # try to set the soft RLIMIT_NOFILE to the hard RLIMIT_NOFILE ceiling. + try: + soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) + resource.setrlimit(resource.RLIMIT_NOFILE, (hard, hard)) + self.addCleanup(resource.setrlimit, resource.RLIMIT_NOFILE, + (soft, hard)) + NUM_FDS = hard + except OSError: + NUM_FDS = soft + + # guard for already allocated FDs (stdin, stdout...) + NUM_FDS -= 32 + + s = self.SELECTOR() + self.addCleanup(s.close) + + r, w = os.pipe() + self.addCleanup(os.close, r) + self.addCleanup(os.close, w) + + for i in range(NUM_FDS): + try: + fd = os.dup(w) + except OSError as e: + if e.errno == errno.EMFILE: + # too many FD, skip + self.skipTest("FD limit reached") + raise + + self.addCleanup(os.close, fd) + s.register(fd, select.EVENT_WRITE) + + self.assertEquals(NUM_FDS, len(s.select())) + + +class SelectorTestCase(BaseSelectorTestCase): + + SELECTOR = select.DefaultSelector + + +class SelectSelectorTestCase(BaseSelectorTestCase): + + SELECTOR = select.SelectSelector + + + at unittest.skipUnless(hasattr(select, 'PollSelector'), + "Test needs select.poll()") +class PollSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn): + + SELECTOR = getattr(select, 'PollSelector', None) + + + at unittest.skipUnless(hasattr(select, 'EpollSelector'), + "Test needs select.epoll()") +class EpollSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn): + + SELECTOR = getattr(select, 'EpollSelector', None) + + + at unittest.skipUnless(hasattr(select, 'KqueueSelector'), + "Test needs select.kqueue()") +class KqueueSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn): + + SELECTOR = getattr(select, 'KqueueSelector', None) + + def test_main(): - support.run_unittest(SelectTestCase) + tests = [SelectTestCase] + tests.extend([SelectorTestCase, SelectSelectorTestCase, + PollSelectorTestCase, EpollSelectorTestCase, + KqueueSelectorTestCase]) + support.run_unittest(*tests) support.reap_children() + if __name__ == "__main__": test_main() diff -r 1287d4c9cd39 Modules/Setup.dist --- a/Modules/Setup.dist Fri Aug 02 10:22:07 2013 +0200 +++ b/Modules/Setup.dist Fri Aug 02 19:45:03 2013 +0200 @@ -188,7 +188,7 @@ #fcntl fcntlmodule.c # fcntl(2) and ioctl(2) #spwd spwdmodule.c # spwd(3) #grp grpmodule.c # grp(3) -#select selectmodule.c # select(2); not on ancient System V +#_select _selectmodule.c # select(2); not on ancient System V # Memory-mapped files (also works on Win32). #mmap mmapmodule.c diff -r 1287d4c9cd39 Modules/_selectmodule.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/_selectmodule.c Fri Aug 02 19:45:03 2013 +0200 @@ -0,0 +1,2334 @@ +/* select - Module containing unix select(2) call. + Under Unix, the file descriptors are small integers. + Under Win32, select only exists for sockets, and sockets may + have any value except INVALID_SOCKET. +*/ + +#include "Python.h" +#include + +#ifdef HAVE_SYS_DEVPOLL_H +#include +#include +#include +#include +#include +#endif + +#ifdef __APPLE__ + /* Perform runtime testing for a broken poll on OSX to make it easier + * to use the same binary on multiple releases of the OS. + */ +#undef HAVE_BROKEN_POLL +#endif + +/* Windows #defines FD_SETSIZE to 64 if FD_SETSIZE isn't already defined. + 64 is too small (too many people have bumped into that limit). + Here we boost it. + Users who want even more than the boosted limit should #define + FD_SETSIZE higher before this; e.g., via compiler /D switch. +*/ +#if defined(MS_WINDOWS) && !defined(FD_SETSIZE) +#define FD_SETSIZE 512 +#endif + +#if defined(HAVE_POLL_H) +#include +#elif defined(HAVE_SYS_POLL_H) +#include +#endif + +#ifdef __sgi +/* This is missing from unistd.h */ +extern void bzero(void *, int); +#endif + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef MS_WINDOWS +# define WIN32_LEAN_AND_MEAN +# include +#else +# define SOCKET int +# if defined(__VMS) +# include +# endif +#endif + +/* list of Python objects and their file descriptor */ +typedef struct { + PyObject *obj; /* owned reference */ + SOCKET fd; + int sentinel; /* -1 == sentinel */ +} pylist; + +static void +reap_obj(pylist fd2obj[FD_SETSIZE + 1]) +{ + int i; + for (i = 0; i < FD_SETSIZE + 1 && fd2obj[i].sentinel >= 0; i++) { + Py_XDECREF(fd2obj[i].obj); + fd2obj[i].obj = NULL; + } + fd2obj[0].sentinel = -1; +} + + +/* returns -1 and sets the Python exception if an error occurred, otherwise + returns a number >= 0 +*/ +static int +seq2set(PyObject *seq, fd_set *set, pylist fd2obj[FD_SETSIZE + 1]) +{ + int max = -1; + int index = 0; + Py_ssize_t i; + PyObject* fast_seq = NULL; + PyObject* o = NULL; + + fd2obj[0].obj = (PyObject*)0; /* set list to zero size */ + FD_ZERO(set); + + fast_seq = PySequence_Fast(seq, "arguments 1-3 must be sequences"); + if (!fast_seq) + return -1; + + for (i = 0; i < PySequence_Fast_GET_SIZE(fast_seq); i++) { + SOCKET v; + + /* any intervening fileno() calls could decr this refcnt */ + if (!(o = PySequence_Fast_GET_ITEM(fast_seq, i))) + goto finally; + + Py_INCREF(o); + v = PyObject_AsFileDescriptor( o ); + if (v == -1) goto finally; + +#if defined(_MSC_VER) + max = 0; /* not used for Win32 */ +#else /* !_MSC_VER */ + if (!_PyIsSelectable_fd(v)) { + PyErr_SetString(PyExc_ValueError, + "filedescriptor out of range in select()"); + goto finally; + } + if (v > max) + max = v; +#endif /* _MSC_VER */ + FD_SET(v, set); + + /* add object and its file descriptor to the list */ + if (index >= FD_SETSIZE) { + PyErr_SetString(PyExc_ValueError, + "too many file descriptors in select()"); + goto finally; + } + fd2obj[index].obj = o; + fd2obj[index].fd = v; + fd2obj[index].sentinel = 0; + fd2obj[++index].sentinel = -1; + } + Py_DECREF(fast_seq); + return max+1; + + finally: + Py_XDECREF(o); + Py_DECREF(fast_seq); + return -1; +} + +/* returns NULL and sets the Python exception if an error occurred */ +static PyObject * +set2list(fd_set *set, pylist fd2obj[FD_SETSIZE + 1]) +{ + int i, j, count=0; + PyObject *list, *o; + SOCKET fd; + + for (j = 0; fd2obj[j].sentinel >= 0; j++) { + if (FD_ISSET(fd2obj[j].fd, set)) + count++; + } + list = PyList_New(count); + if (!list) + return NULL; + + i = 0; + for (j = 0; fd2obj[j].sentinel >= 0; j++) { + fd = fd2obj[j].fd; + if (FD_ISSET(fd, set)) { + o = fd2obj[j].obj; + fd2obj[j].obj = NULL; + /* transfer ownership */ + if (PyList_SetItem(list, i, o) < 0) + goto finally; + + i++; + } + } + return list; + finally: + Py_DECREF(list); + return NULL; +} + +#undef SELECT_USES_HEAP +#if FD_SETSIZE > 1024 +#define SELECT_USES_HEAP +#endif /* FD_SETSIZE > 1024 */ + +static PyObject * +select_select(PyObject *self, PyObject *args) +{ +#ifdef SELECT_USES_HEAP + pylist *rfd2obj, *wfd2obj, *efd2obj; +#else /* !SELECT_USES_HEAP */ + /* XXX: All this should probably be implemented as follows: + * - find the highest descriptor we're interested in + * - add one + * - that's the size + * See: Stevens, APitUE, $12.5.1 + */ + pylist rfd2obj[FD_SETSIZE + 1]; + pylist wfd2obj[FD_SETSIZE + 1]; + pylist efd2obj[FD_SETSIZE + 1]; +#endif /* SELECT_USES_HEAP */ + PyObject *ifdlist, *ofdlist, *efdlist; + PyObject *ret = NULL; + PyObject *tout = Py_None; + fd_set ifdset, ofdset, efdset; + struct timeval tv, *tvp; + int imax, omax, emax, max; + int n; + + /* convert arguments */ + if (!PyArg_UnpackTuple(args, "select", 3, 4, + &ifdlist, &ofdlist, &efdlist, &tout)) + return NULL; + + if (tout == Py_None) + tvp = (struct timeval *)0; + else if (!PyNumber_Check(tout)) { + PyErr_SetString(PyExc_TypeError, + "timeout must be a float or None"); + return NULL; + } + else { +#ifdef MS_WINDOWS + time_t sec; + if (_PyTime_ObjectToTimeval(tout, &sec, &tv.tv_usec) == -1) + return NULL; + assert(sizeof(tv.tv_sec) == sizeof(long)); +#if SIZEOF_TIME_T > SIZEOF_LONG + if (sec > LONG_MAX) { + PyErr_SetString(PyExc_OverflowError, + "timeout is too large"); + return NULL; + } +#endif + tv.tv_sec = (long)sec; +#else + /* 64-bit OS X has struct timeval.tv_usec as an int (and thus still 4 + bytes as required), but no longer defined by a long. */ + long tv_usec; + if (_PyTime_ObjectToTimeval(tout, &tv.tv_sec, &tv_usec) == -1) + return NULL; + tv.tv_usec = tv_usec; +#endif + if (tv.tv_sec < 0) { + PyErr_SetString(PyExc_ValueError, "timeout must be non-negative"); + return NULL; + } + tvp = &tv; + } + + +#ifdef SELECT_USES_HEAP + /* Allocate memory for the lists */ + rfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1); + wfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1); + efd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1); + if (rfd2obj == NULL || wfd2obj == NULL || efd2obj == NULL) { + if (rfd2obj) PyMem_DEL(rfd2obj); + if (wfd2obj) PyMem_DEL(wfd2obj); + if (efd2obj) PyMem_DEL(efd2obj); + return PyErr_NoMemory(); + } +#endif /* SELECT_USES_HEAP */ + /* Convert sequences to fd_sets, and get maximum fd number + * propagates the Python exception set in seq2set() + */ + rfd2obj[0].sentinel = -1; + wfd2obj[0].sentinel = -1; + efd2obj[0].sentinel = -1; + if ((imax=seq2set(ifdlist, &ifdset, rfd2obj)) < 0) + goto finally; + if ((omax=seq2set(ofdlist, &ofdset, wfd2obj)) < 0) + goto finally; + if ((emax=seq2set(efdlist, &efdset, efd2obj)) < 0) + goto finally; + max = imax; + if (omax > max) max = omax; + if (emax > max) max = emax; + + Py_BEGIN_ALLOW_THREADS + n = select(max, &ifdset, &ofdset, &efdset, tvp); + Py_END_ALLOW_THREADS + +#ifdef MS_WINDOWS + if (n == SOCKET_ERROR) { + PyErr_SetExcFromWindowsErr(PyExc_OSError, WSAGetLastError()); + } +#else + if (n < 0) { + PyErr_SetFromErrno(PyExc_OSError); + } +#endif + else { + /* any of these three calls can raise an exception. it's more + convenient to test for this after all three calls... but + is that acceptable? + */ + ifdlist = set2list(&ifdset, rfd2obj); + ofdlist = set2list(&ofdset, wfd2obj); + efdlist = set2list(&efdset, efd2obj); + if (PyErr_Occurred()) + ret = NULL; + else + ret = PyTuple_Pack(3, ifdlist, ofdlist, efdlist); + + Py_XDECREF(ifdlist); + Py_XDECREF(ofdlist); + Py_XDECREF(efdlist); + } + + finally: + reap_obj(rfd2obj); + reap_obj(wfd2obj); + reap_obj(efd2obj); +#ifdef SELECT_USES_HEAP + PyMem_DEL(rfd2obj); + PyMem_DEL(wfd2obj); + PyMem_DEL(efd2obj); +#endif /* SELECT_USES_HEAP */ + return ret; +} + +#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) +/* + * poll() support + */ + +typedef struct { + PyObject_HEAD + PyObject *dict; + int ufd_uptodate; + int ufd_len; + struct pollfd *ufds; +} pollObject; + +static PyTypeObject poll_Type; + +/* Update the malloc'ed array of pollfds to match the dictionary + contained within a pollObject. Return 1 on success, 0 on an error. +*/ + +static int +update_ufd_array(pollObject *self) +{ + Py_ssize_t i, pos; + PyObject *key, *value; + struct pollfd *old_ufds = self->ufds; + + self->ufd_len = PyDict_Size(self->dict); + PyMem_RESIZE(self->ufds, struct pollfd, self->ufd_len); + if (self->ufds == NULL) { + self->ufds = old_ufds; + PyErr_NoMemory(); + return 0; + } + + i = pos = 0; + while (PyDict_Next(self->dict, &pos, &key, &value)) { + assert(i < self->ufd_len); + /* Never overflow */ + self->ufds[i].fd = (int)PyLong_AsLong(key); + self->ufds[i].events = (short)PyLong_AsLong(value); + i++; + } + assert(i == self->ufd_len); + self->ufd_uptodate = 1; + return 1; +} + +PyDoc_STRVAR(poll_register_doc, +"register(fd [, eventmask] ) -> None\n\n\ +Register a file descriptor with the polling object.\n\ +fd -- either an integer, or an object with a fileno() method returning an\n\ + int.\n\ +events -- an optional bitmask describing the type of events to check for"); + +static PyObject * +poll_register(pollObject *self, PyObject *args) +{ + PyObject *o, *key, *value; + int fd; + short events = POLLIN | POLLPRI | POLLOUT; + int err; + + if (!PyArg_ParseTuple(args, "O|h:register", &o, &events)) { + return NULL; + } + + fd = PyObject_AsFileDescriptor(o); + if (fd == -1) return NULL; + + /* Add entry to the internal dictionary: the key is the + file descriptor, and the value is the event mask. */ + key = PyLong_FromLong(fd); + if (key == NULL) + return NULL; + value = PyLong_FromLong(events); + if (value == NULL) { + Py_DECREF(key); + return NULL; + } + err = PyDict_SetItem(self->dict, key, value); + Py_DECREF(key); + Py_DECREF(value); + if (err < 0) + return NULL; + + self->ufd_uptodate = 0; + + Py_INCREF(Py_None); + return Py_None; +} + +PyDoc_STRVAR(poll_modify_doc, +"modify(fd, eventmask) -> None\n\n\ +Modify an already registered file descriptor.\n\ +fd -- either an integer, or an object with a fileno() method returning an\n\ + int.\n\ +events -- an optional bitmask describing the type of events to check for"); + +static PyObject * +poll_modify(pollObject *self, PyObject *args) +{ + PyObject *o, *key, *value; + int fd, events; + int err; + + if (!PyArg_ParseTuple(args, "Oi:modify", &o, &events)) { + return NULL; + } + + fd = PyObject_AsFileDescriptor(o); + if (fd == -1) return NULL; + + /* Modify registered fd */ + key = PyLong_FromLong(fd); + if (key == NULL) + return NULL; + if (PyDict_GetItem(self->dict, key) == NULL) { + errno = ENOENT; + PyErr_SetFromErrno(PyExc_OSError); + Py_DECREF(key); + return NULL; + } + value = PyLong_FromLong(events); + if (value == NULL) { + Py_DECREF(key); + return NULL; + } + err = PyDict_SetItem(self->dict, key, value); + Py_DECREF(key); + Py_DECREF(value); + if (err < 0) + return NULL; + + self->ufd_uptodate = 0; + + Py_INCREF(Py_None); + return Py_None; +} + + +PyDoc_STRVAR(poll_unregister_doc, +"unregister(fd) -> None\n\n\ +Remove a file descriptor being tracked by the polling object."); + +static PyObject * +poll_unregister(pollObject *self, PyObject *o) +{ + PyObject *key; + int fd; + + fd = PyObject_AsFileDescriptor( o ); + if (fd == -1) + return NULL; + + /* Check whether the fd is already in the array */ + key = PyLong_FromLong(fd); + if (key == NULL) + return NULL; + + if (PyDict_DelItem(self->dict, key) == -1) { + Py_DECREF(key); + /* This will simply raise the KeyError set by PyDict_DelItem + if the file descriptor isn't registered. */ + return NULL; + } + + Py_DECREF(key); + self->ufd_uptodate = 0; + + Py_INCREF(Py_None); + return Py_None; +} + +PyDoc_STRVAR(poll_poll_doc, +"poll( [timeout] ) -> list of (fd, event) 2-tuples\n\n\ +Polls the set of registered file descriptors, returning a list containing \n\ +any descriptors that have events or errors to report."); + +static PyObject * +poll_poll(pollObject *self, PyObject *args) +{ + PyObject *result_list = NULL, *tout = NULL; + int timeout = 0, poll_result, i, j; + PyObject *value = NULL, *num = NULL; + + if (!PyArg_UnpackTuple(args, "poll", 0, 1, &tout)) { + return NULL; + } + + /* Check values for timeout */ + if (tout == NULL || tout == Py_None) + timeout = -1; + else if (!PyNumber_Check(tout)) { + PyErr_SetString(PyExc_TypeError, + "timeout must be an integer or None"); + return NULL; + } + else { + tout = PyNumber_Long(tout); + if (!tout) + return NULL; + timeout = _PyLong_AsInt(tout); + Py_DECREF(tout); + if (timeout == -1 && PyErr_Occurred()) + return NULL; + } + + /* Ensure the ufd array is up to date */ + if (!self->ufd_uptodate) + if (update_ufd_array(self) == 0) + return NULL; + + /* call poll() */ + Py_BEGIN_ALLOW_THREADS + poll_result = poll(self->ufds, self->ufd_len, timeout); + Py_END_ALLOW_THREADS + + if (poll_result < 0) { + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + } + + /* build the result list */ + + result_list = PyList_New(poll_result); + if (!result_list) + return NULL; + else { + for (i = 0, j = 0; j < poll_result; j++) { + /* skip to the next fired descriptor */ + while (!self->ufds[i].revents) { + i++; + } + /* if we hit a NULL return, set value to NULL + and break out of loop; code at end will + clean up result_list */ + value = PyTuple_New(2); + if (value == NULL) + goto error; + num = PyLong_FromLong(self->ufds[i].fd); + if (num == NULL) { + Py_DECREF(value); + goto error; + } + PyTuple_SET_ITEM(value, 0, num); + + /* The &0xffff is a workaround for AIX. 'revents' + is a 16-bit short, and IBM assigned POLLNVAL + to be 0x8000, so the conversion to int results + in a negative number. See SF bug #923315. */ + num = PyLong_FromLong(self->ufds[i].revents & 0xffff); + if (num == NULL) { + Py_DECREF(value); + goto error; + } + PyTuple_SET_ITEM(value, 1, num); + if ((PyList_SetItem(result_list, j, value)) == -1) { + Py_DECREF(value); + goto error; + } + i++; + } + } + return result_list; + + error: + Py_DECREF(result_list); + return NULL; +} + +static PyMethodDef poll_methods[] = { + {"register", (PyCFunction)poll_register, + METH_VARARGS, poll_register_doc}, + {"modify", (PyCFunction)poll_modify, + METH_VARARGS, poll_modify_doc}, + {"unregister", (PyCFunction)poll_unregister, + METH_O, poll_unregister_doc}, + {"poll", (PyCFunction)poll_poll, + METH_VARARGS, poll_poll_doc}, + {NULL, NULL} /* sentinel */ +}; + +static pollObject * +newPollObject(void) +{ + pollObject *self; + self = PyObject_New(pollObject, &poll_Type); + if (self == NULL) + return NULL; + /* ufd_uptodate is a Boolean, denoting whether the + array pointed to by ufds matches the contents of the dictionary. */ + self->ufd_uptodate = 0; + self->ufds = NULL; + self->dict = PyDict_New(); + if (self->dict == NULL) { + Py_DECREF(self); + return NULL; + } + return self; +} + +static void +poll_dealloc(pollObject *self) +{ + if (self->ufds != NULL) + PyMem_DEL(self->ufds); + Py_XDECREF(self->dict); + PyObject_Del(self); +} + +static PyTypeObject poll_Type = { + /* The ob_type field must be initialized in the module init function + * to be portable to Windows without using C++. */ + PyVarObject_HEAD_INIT(NULL, 0) + "select.poll", /*tp_name*/ + sizeof(pollObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + (destructor)poll_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_reserved*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + poll_methods, /*tp_methods*/ +}; + +#ifdef HAVE_SYS_DEVPOLL_H +typedef struct { + PyObject_HEAD + int fd_devpoll; + int max_n_fds; + int n_fds; + struct pollfd *fds; +} devpollObject; + +static PyTypeObject devpoll_Type; + +static int devpoll_flush(devpollObject *self) +{ + int size, n; + + if (!self->n_fds) return 0; + + size = sizeof(struct pollfd)*self->n_fds; + self->n_fds = 0; + + Py_BEGIN_ALLOW_THREADS + n = write(self->fd_devpoll, self->fds, size); + Py_END_ALLOW_THREADS + + if (n == -1 ) { + PyErr_SetFromErrno(PyExc_IOError); + return -1; + } + if (n < size) { + /* + ** Data writed to /dev/poll is a binary data structure. It is not + ** clear what to do if a partial write occurred. For now, raise + ** an exception and see if we actually found this problem in + ** the wild. + ** See http://bugs.python.org/issue6397. + */ + PyErr_Format(PyExc_IOError, "failed to write all pollfds. " + "Please, report at http://bugs.python.org/. " + "Data to report: Size tried: %d, actual size written: %d.", + size, n); + return -1; + } + return 0; +} + +static PyObject * +internal_devpoll_register(devpollObject *self, PyObject *args, int remove) +{ + PyObject *o; + int fd, events = POLLIN | POLLPRI | POLLOUT; + + if (!PyArg_ParseTuple(args, "O|i:register", &o, &events)) { + return NULL; + } + + fd = PyObject_AsFileDescriptor(o); + if (fd == -1) return NULL; + + if (remove) { + self->fds[self->n_fds].fd = fd; + self->fds[self->n_fds].events = POLLREMOVE; + + if (++self->n_fds == self->max_n_fds) { + if (devpoll_flush(self)) + return NULL; + } + } + + self->fds[self->n_fds].fd = fd; + self->fds[self->n_fds].events = events; + + if (++self->n_fds == self->max_n_fds) { + if (devpoll_flush(self)) + return NULL; + } + + Py_RETURN_NONE; +} + +PyDoc_STRVAR(devpoll_register_doc, +"register(fd [, eventmask] ) -> None\n\n\ +Register a file descriptor with the polling object.\n\ +fd -- either an integer, or an object with a fileno() method returning an\n\ + int.\n\ +events -- an optional bitmask describing the type of events to check for"); + +static PyObject * +devpoll_register(devpollObject *self, PyObject *args) +{ + return internal_devpoll_register(self, args, 0); +} + +PyDoc_STRVAR(devpoll_modify_doc, +"modify(fd[, eventmask]) -> None\n\n\ +Modify a possible already registered file descriptor.\n\ +fd -- either an integer, or an object with a fileno() method returning an\n\ + int.\n\ +events -- an optional bitmask describing the type of events to check for"); + +static PyObject * +devpoll_modify(devpollObject *self, PyObject *args) +{ + return internal_devpoll_register(self, args, 1); +} + + +PyDoc_STRVAR(devpoll_unregister_doc, +"unregister(fd) -> None\n\n\ +Remove a file descriptor being tracked by the polling object."); + +static PyObject * +devpoll_unregister(devpollObject *self, PyObject *o) +{ + int fd; + + fd = PyObject_AsFileDescriptor( o ); + if (fd == -1) + return NULL; + + self->fds[self->n_fds].fd = fd; + self->fds[self->n_fds].events = POLLREMOVE; + + if (++self->n_fds == self->max_n_fds) { + if (devpoll_flush(self)) + return NULL; + } + + Py_RETURN_NONE; +} + +PyDoc_STRVAR(devpoll_poll_doc, +"poll( [timeout] ) -> list of (fd, event) 2-tuples\n\n\ +Polls the set of registered file descriptors, returning a list containing \n\ +any descriptors that have events or errors to report."); + +static PyObject * +devpoll_poll(devpollObject *self, PyObject *args) +{ + struct dvpoll dvp; + PyObject *result_list = NULL, *tout = NULL; + int poll_result, i; + long timeout; + PyObject *value, *num1, *num2; + + if (!PyArg_UnpackTuple(args, "poll", 0, 1, &tout)) { + return NULL; + } + + /* Check values for timeout */ + if (tout == NULL || tout == Py_None) + timeout = -1; + else if (!PyNumber_Check(tout)) { + PyErr_SetString(PyExc_TypeError, + "timeout must be an integer or None"); + return NULL; + } + else { + tout = PyNumber_Long(tout); + if (!tout) + return NULL; + timeout = PyLong_AsLong(tout); + Py_DECREF(tout); + if (timeout == -1 && PyErr_Occurred()) + return NULL; + } + + if ((timeout < -1) || (timeout > INT_MAX)) { + PyErr_SetString(PyExc_OverflowError, + "timeout is out of range"); + return NULL; + } + + if (devpoll_flush(self)) + return NULL; + + dvp.dp_fds = self->fds; + dvp.dp_nfds = self->max_n_fds; + dvp.dp_timeout = timeout; + + /* call devpoll() */ + Py_BEGIN_ALLOW_THREADS + poll_result = ioctl(self->fd_devpoll, DP_POLL, &dvp); + Py_END_ALLOW_THREADS + + if (poll_result < 0) { + PyErr_SetFromErrno(PyExc_IOError); + return NULL; + } + + /* build the result list */ + + result_list = PyList_New(poll_result); + if (!result_list) + return NULL; + else { + for (i = 0; i < poll_result; i++) { + num1 = PyLong_FromLong(self->fds[i].fd); + num2 = PyLong_FromLong(self->fds[i].revents); + if ((num1 == NULL) || (num2 == NULL)) { + Py_XDECREF(num1); + Py_XDECREF(num2); + goto error; + } + value = PyTuple_Pack(2, num1, num2); + Py_DECREF(num1); + Py_DECREF(num2); + if (value == NULL) + goto error; + if ((PyList_SetItem(result_list, i, value)) == -1) { + Py_DECREF(value); + goto error; + } + } + } + + return result_list; + + error: + Py_DECREF(result_list); + return NULL; +} + +static PyMethodDef devpoll_methods[] = { + {"register", (PyCFunction)devpoll_register, + METH_VARARGS, devpoll_register_doc}, + {"modify", (PyCFunction)devpoll_modify, + METH_VARARGS, devpoll_modify_doc}, + {"unregister", (PyCFunction)devpoll_unregister, + METH_O, devpoll_unregister_doc}, + {"poll", (PyCFunction)devpoll_poll, + METH_VARARGS, devpoll_poll_doc}, + {NULL, NULL} /* sentinel */ +}; + +static devpollObject * +newDevPollObject(void) +{ + devpollObject *self; + int fd_devpoll, limit_result; + struct pollfd *fds; + struct rlimit limit; + + Py_BEGIN_ALLOW_THREADS + /* + ** If we try to process more that getrlimit() + ** fds, the kernel will give an error, so + ** we set the limit here. It is a dynamic + ** value, because we can change rlimit() anytime. + */ + limit_result = getrlimit(RLIMIT_NOFILE, &limit); + if (limit_result != -1) + fd_devpoll = open("/dev/poll", O_RDWR); + Py_END_ALLOW_THREADS + + if (limit_result == -1) { + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + } + if (fd_devpoll == -1) { + PyErr_SetFromErrnoWithFilename(PyExc_IOError, "/dev/poll"); + return NULL; + } + + fds = PyMem_NEW(struct pollfd, limit.rlim_cur); + if (fds == NULL) { + close(fd_devpoll); + PyErr_NoMemory(); + return NULL; + } + + self = PyObject_New(devpollObject, &devpoll_Type); + if (self == NULL) { + close(fd_devpoll); + PyMem_DEL(fds); + return NULL; + } + self->fd_devpoll = fd_devpoll; + self->max_n_fds = limit.rlim_cur; + self->n_fds = 0; + self->fds = fds; + + return self; +} + +static void +devpoll_dealloc(devpollObject *self) +{ + Py_BEGIN_ALLOW_THREADS + close(self->fd_devpoll); + Py_END_ALLOW_THREADS + + PyMem_DEL(self->fds); + + PyObject_Del(self); +} + +static PyTypeObject devpoll_Type = { + /* The ob_type field must be initialized in the module init function + * to be portable to Windows without using C++. */ + PyVarObject_HEAD_INIT(NULL, 0) + "select.devpoll", /*tp_name*/ + sizeof(devpollObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + (destructor)devpoll_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_reserved*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + devpoll_methods, /*tp_methods*/ +}; +#endif /* HAVE_SYS_DEVPOLL_H */ + + + +PyDoc_STRVAR(poll_doc, +"Returns a polling object, which supports registering and\n\ +unregistering file descriptors, and then polling them for I/O events."); + +static PyObject * +select_poll(PyObject *self, PyObject *unused) +{ + return (PyObject *)newPollObject(); +} + +#ifdef HAVE_SYS_DEVPOLL_H +PyDoc_STRVAR(devpoll_doc, +"Returns a polling object, which supports registering and\n\ +unregistering file descriptors, and then polling them for I/O events."); + +static PyObject * +select_devpoll(PyObject *self, PyObject *unused) +{ + return (PyObject *)newDevPollObject(); +} +#endif + + +#ifdef __APPLE__ +/* + * On some systems poll() sets errno on invalid file descriptors. We test + * for this at runtime because this bug may be fixed or introduced between + * OS releases. + */ +static int select_have_broken_poll(void) +{ + int poll_test; + int filedes[2]; + + struct pollfd poll_struct = { 0, POLLIN|POLLPRI|POLLOUT, 0 }; + + /* Create a file descriptor to make invalid */ + if (pipe(filedes) < 0) { + return 1; + } + poll_struct.fd = filedes[0]; + close(filedes[0]); + close(filedes[1]); + poll_test = poll(&poll_struct, 1, 0); + if (poll_test < 0) { + return 1; + } else if (poll_test == 0 && poll_struct.revents != POLLNVAL) { + return 1; + } + return 0; +} +#endif /* __APPLE__ */ + +#endif /* HAVE_POLL */ + +#ifdef HAVE_EPOLL +/* ************************************************************************** + * epoll interface for Linux 2.6 + * + * Written by Christian Heimes + * Inspired by Twisted's _epoll.pyx and select.poll() + */ + +#ifdef HAVE_SYS_EPOLL_H +#include +#endif + +typedef struct { + PyObject_HEAD + SOCKET epfd; /* epoll control file descriptor */ +} pyEpoll_Object; + +static PyTypeObject pyEpoll_Type; +#define pyepoll_CHECK(op) (PyObject_TypeCheck((op), &pyEpoll_Type)) + +static PyObject * +pyepoll_err_closed(void) +{ + PyErr_SetString(PyExc_ValueError, "I/O operation on closed epoll fd"); + return NULL; +} + +static int +pyepoll_internal_close(pyEpoll_Object *self) +{ + int save_errno = 0; + if (self->epfd >= 0) { + int epfd = self->epfd; + self->epfd = -1; + Py_BEGIN_ALLOW_THREADS + if (close(epfd) < 0) + save_errno = errno; + Py_END_ALLOW_THREADS + } + return save_errno; +} + +static PyObject * +newPyEpoll_Object(PyTypeObject *type, int sizehint, int flags, SOCKET fd) +{ + pyEpoll_Object *self; + + assert(type != NULL && type->tp_alloc != NULL); + self = (pyEpoll_Object *) type->tp_alloc(type, 0); + if (self == NULL) + return NULL; + + if (fd == -1) { + Py_BEGIN_ALLOW_THREADS +#ifdef HAVE_EPOLL_CREATE1 + if (flags) + self->epfd = epoll_create1(flags); + else +#endif + self->epfd = epoll_create(sizehint); + Py_END_ALLOW_THREADS + } + else { + self->epfd = fd; + } + if (self->epfd < 0) { + Py_DECREF(self); + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + } + return (PyObject *)self; +} + + +static PyObject * +pyepoll_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + int flags = 0, sizehint = FD_SETSIZE - 1; + static char *kwlist[] = {"sizehint", "flags", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|ii:epoll", kwlist, + &sizehint, &flags)) + return NULL; + if (sizehint < 0) { + PyErr_SetString(PyExc_ValueError, "negative sizehint"); + return NULL; + } + + return newPyEpoll_Object(type, sizehint, flags, -1); +} + + +static void +pyepoll_dealloc(pyEpoll_Object *self) +{ + (void)pyepoll_internal_close(self); + Py_TYPE(self)->tp_free(self); +} + +static PyObject* +pyepoll_close(pyEpoll_Object *self) +{ + errno = pyepoll_internal_close(self); + if (errno < 0) { + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + } + Py_RETURN_NONE; +} + +PyDoc_STRVAR(pyepoll_close_doc, +"close() -> None\n\ +\n\ +Close the epoll control file descriptor. Further operations on the epoll\n\ +object will raise an exception."); + +static PyObject* +pyepoll_get_closed(pyEpoll_Object *self) +{ + if (self->epfd < 0) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +static PyObject* +pyepoll_fileno(pyEpoll_Object *self) +{ + if (self->epfd < 0) + return pyepoll_err_closed(); + return PyLong_FromLong(self->epfd); +} + +PyDoc_STRVAR(pyepoll_fileno_doc, +"fileno() -> int\n\ +\n\ +Return the epoll control file descriptor."); + +static PyObject* +pyepoll_fromfd(PyObject *cls, PyObject *args) +{ + SOCKET fd; + + if (!PyArg_ParseTuple(args, "i:fromfd", &fd)) + return NULL; + + return newPyEpoll_Object((PyTypeObject*)cls, FD_SETSIZE - 1, 0, fd); +} + +PyDoc_STRVAR(pyepoll_fromfd_doc, +"fromfd(fd) -> epoll\n\ +\n\ +Create an epoll object from a given control fd."); + +static PyObject * +pyepoll_internal_ctl(int epfd, int op, PyObject *pfd, unsigned int events) +{ + struct epoll_event ev; + int result; + int fd; + + if (epfd < 0) + return pyepoll_err_closed(); + + fd = PyObject_AsFileDescriptor(pfd); + if (fd == -1) { + return NULL; + } + + switch(op) { + case EPOLL_CTL_ADD: + case EPOLL_CTL_MOD: + ev.events = events; + ev.data.fd = fd; + Py_BEGIN_ALLOW_THREADS + result = epoll_ctl(epfd, op, fd, &ev); + Py_END_ALLOW_THREADS + break; + case EPOLL_CTL_DEL: + /* In kernel versions before 2.6.9, the EPOLL_CTL_DEL + * operation required a non-NULL pointer in event, even + * though this argument is ignored. */ + Py_BEGIN_ALLOW_THREADS + result = epoll_ctl(epfd, op, fd, &ev); + if (errno == EBADF) { + /* fd already closed */ + result = 0; + errno = 0; + } + Py_END_ALLOW_THREADS + break; + default: + result = -1; + errno = EINVAL; + } + + if (result < 0) { + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + } + Py_RETURN_NONE; +} + +static PyObject * +pyepoll_register(pyEpoll_Object *self, PyObject *args, PyObject *kwds) +{ + PyObject *pfd; + unsigned int events = EPOLLIN | EPOLLOUT | EPOLLPRI; + static char *kwlist[] = {"fd", "eventmask", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|I:register", kwlist, + &pfd, &events)) { + return NULL; + } + + return pyepoll_internal_ctl(self->epfd, EPOLL_CTL_ADD, pfd, events); +} + +PyDoc_STRVAR(pyepoll_register_doc, +"register(fd[, eventmask]) -> None\n\ +\n\ +Registers a new fd or raises an OSError if the fd is already registered.\n\ +fd is the target file descriptor of the operation.\n\ +events is a bit set composed of the various EPOLL constants; the default\n\ +is EPOLL_IN | EPOLL_OUT | EPOLL_PRI.\n\ +\n\ +The epoll interface supports all file descriptors that support poll."); + +static PyObject * +pyepoll_modify(pyEpoll_Object *self, PyObject *args, PyObject *kwds) +{ + PyObject *pfd; + unsigned int events; + static char *kwlist[] = {"fd", "eventmask", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "OI:modify", kwlist, + &pfd, &events)) { + return NULL; + } + + return pyepoll_internal_ctl(self->epfd, EPOLL_CTL_MOD, pfd, events); +} + +PyDoc_STRVAR(pyepoll_modify_doc, +"modify(fd, eventmask) -> None\n\ +\n\ +fd is the target file descriptor of the operation\n\ +events is a bit set composed of the various EPOLL constants"); + +static PyObject * +pyepoll_unregister(pyEpoll_Object *self, PyObject *args, PyObject *kwds) +{ + PyObject *pfd; + static char *kwlist[] = {"fd", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:unregister", kwlist, + &pfd)) { + return NULL; + } + + return pyepoll_internal_ctl(self->epfd, EPOLL_CTL_DEL, pfd, 0); +} + +PyDoc_STRVAR(pyepoll_unregister_doc, +"unregister(fd) -> None\n\ +\n\ +fd is the target file descriptor of the operation."); + +static PyObject * +pyepoll_poll(pyEpoll_Object *self, PyObject *args, PyObject *kwds) +{ + double dtimeout = -1.; + int timeout; + int maxevents = -1; + int nfds, i; + PyObject *elist = NULL, *etuple = NULL; + struct epoll_event *evs = NULL; + static char *kwlist[] = {"timeout", "maxevents", NULL}; + + if (self->epfd < 0) + return pyepoll_err_closed(); + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|di:poll", kwlist, + &dtimeout, &maxevents)) { + return NULL; + } + + if (dtimeout < 0) { + timeout = -1; + } + else if (dtimeout * 1000.0 > INT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "timeout is too large"); + return NULL; + } + else { + timeout = (int)(dtimeout * 1000.0); + } + + if (maxevents == -1) { + maxevents = FD_SETSIZE-1; + } + else if (maxevents < 1) { + PyErr_Format(PyExc_ValueError, + "maxevents must be greater than 0, got %d", + maxevents); + return NULL; + } + + evs = PyMem_New(struct epoll_event, maxevents); + if (evs == NULL) { + Py_DECREF(self); + PyErr_NoMemory(); + return NULL; + } + + Py_BEGIN_ALLOW_THREADS + nfds = epoll_wait(self->epfd, evs, maxevents, timeout); + Py_END_ALLOW_THREADS + if (nfds < 0) { + PyErr_SetFromErrno(PyExc_OSError); + goto error; + } + + elist = PyList_New(nfds); + if (elist == NULL) { + goto error; + } + + for (i = 0; i < nfds; i++) { + etuple = Py_BuildValue("iI", evs[i].data.fd, evs[i].events); + if (etuple == NULL) { + Py_CLEAR(elist); + goto error; + } + PyList_SET_ITEM(elist, i, etuple); + } + + error: + PyMem_Free(evs); + return elist; +} + +PyDoc_STRVAR(pyepoll_poll_doc, +"poll([timeout=-1[, maxevents=-1]]) -> [(fd, events), (...)]\n\ +\n\ +Wait for events on the epoll file descriptor for a maximum time of timeout\n\ +in seconds (as float). -1 makes poll wait indefinitely.\n\ +Up to maxevents are returned to the caller."); + +static PyObject * +pyepoll_enter(pyEpoll_Object *self, PyObject *args) +{ + if (self->epfd < 0) + return pyepoll_err_closed(); + + Py_INCREF(self); + return (PyObject *)self; +} + +static PyObject * +pyepoll_exit(PyObject *self, PyObject *args) +{ + _Py_IDENTIFIER(close); + + return _PyObject_CallMethodId(self, &PyId_close, NULL); +} + +static PyMethodDef pyepoll_methods[] = { + {"fromfd", (PyCFunction)pyepoll_fromfd, + METH_VARARGS | METH_CLASS, pyepoll_fromfd_doc}, + {"close", (PyCFunction)pyepoll_close, METH_NOARGS, + pyepoll_close_doc}, + {"fileno", (PyCFunction)pyepoll_fileno, METH_NOARGS, + pyepoll_fileno_doc}, + {"modify", (PyCFunction)pyepoll_modify, + METH_VARARGS | METH_KEYWORDS, pyepoll_modify_doc}, + {"register", (PyCFunction)pyepoll_register, + METH_VARARGS | METH_KEYWORDS, pyepoll_register_doc}, + {"unregister", (PyCFunction)pyepoll_unregister, + METH_VARARGS | METH_KEYWORDS, pyepoll_unregister_doc}, + {"poll", (PyCFunction)pyepoll_poll, + METH_VARARGS | METH_KEYWORDS, pyepoll_poll_doc}, + {"__enter__", (PyCFunction)pyepoll_enter, METH_NOARGS, + NULL}, + {"__exit__", (PyCFunction)pyepoll_exit, METH_VARARGS, + NULL}, + {NULL, NULL}, +}; + +static PyGetSetDef pyepoll_getsetlist[] = { + {"closed", (getter)pyepoll_get_closed, NULL, + "True if the epoll handler is closed"}, + {0}, +}; + +PyDoc_STRVAR(pyepoll_doc, +"select.epoll(sizehint=-1, flags=0)\n\ +\n\ +Returns an epolling object\n\ +\n\ +sizehint must be a positive integer or -1 for the default size. The\n\ +sizehint is used to optimize internal data structures. It doesn't limit\n\ +the maximum number of monitored events."); + +static PyTypeObject pyEpoll_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "select.epoll", /* tp_name */ + sizeof(pyEpoll_Object), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)pyepoll_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + pyepoll_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + pyepoll_methods, /* tp_methods */ + 0, /* tp_members */ + pyepoll_getsetlist, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + pyepoll_new, /* tp_new */ + 0, /* tp_free */ +}; + +#endif /* HAVE_EPOLL */ + +#ifdef HAVE_KQUEUE +/* ************************************************************************** + * kqueue interface for BSD + * + * Copyright (c) 2000 Doug White, 2006 James Knight, 2007 Christian Heimes + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_SYS_EVENT_H +#include +#endif + +PyDoc_STRVAR(kqueue_event_doc, +"kevent(ident, filter=KQ_FILTER_READ, flags=KQ_EV_ADD, fflags=0, data=0, udata=0)\n\ +\n\ +This object is the equivalent of the struct kevent for the C API.\n\ +\n\ +See the kqueue manpage for more detailed information about the meaning\n\ +of the arguments.\n\ +\n\ +One minor note: while you might hope that udata could store a\n\ +reference to a python object, it cannot, because it is impossible to\n\ +keep a proper reference count of the object once it's passed into the\n\ +kernel. Therefore, I have restricted it to only storing an integer. I\n\ +recommend ignoring it and simply using the 'ident' field to key off\n\ +of. You could also set up a dictionary on the python side to store a\n\ +udata->object mapping."); + +typedef struct { + PyObject_HEAD + struct kevent e; +} kqueue_event_Object; + +static PyTypeObject kqueue_event_Type; + +#define kqueue_event_Check(op) (PyObject_TypeCheck((op), &kqueue_event_Type)) + +typedef struct { + PyObject_HEAD + SOCKET kqfd; /* kqueue control fd */ +} kqueue_queue_Object; + +static PyTypeObject kqueue_queue_Type; + +#define kqueue_queue_Check(op) (PyObject_TypeCheck((op), &kqueue_queue_Type)) + +#if (SIZEOF_UINTPTR_T != SIZEOF_VOID_P) +# error uintptr_t does not match void *! +#elif (SIZEOF_UINTPTR_T == SIZEOF_LONG_LONG) +# define T_UINTPTRT T_ULONGLONG +# define T_INTPTRT T_LONGLONG +# define PyLong_AsUintptr_t PyLong_AsUnsignedLongLong +# define UINTPTRT_FMT_UNIT "K" +# define INTPTRT_FMT_UNIT "L" +#elif (SIZEOF_UINTPTR_T == SIZEOF_LONG) +# define T_UINTPTRT T_ULONG +# define T_INTPTRT T_LONG +# define PyLong_AsUintptr_t PyLong_AsUnsignedLong +# define UINTPTRT_FMT_UNIT "k" +# define INTPTRT_FMT_UNIT "l" +#elif (SIZEOF_UINTPTR_T == SIZEOF_INT) +# define T_UINTPTRT T_UINT +# define T_INTPTRT T_INT +# define PyLong_AsUintptr_t PyLong_AsUnsignedLong +# define UINTPTRT_FMT_UNIT "I" +# define INTPTRT_FMT_UNIT "i" +#else +# error uintptr_t does not match int, long, or long long! +#endif + +/* + * kevent is not standard and its members vary across BSDs. + */ +#if !defined(__OpenBSD__) +# define IDENT_TYPE T_UINTPTRT +# define IDENT_CAST Py_intptr_t +# define DATA_TYPE T_INTPTRT +# define DATA_FMT_UNIT INTPTRT_FMT_UNIT +# define IDENT_AsType PyLong_AsUintptr_t +#else +# define IDENT_TYPE T_UINT +# define IDENT_CAST int +# define DATA_TYPE T_INT +# define DATA_FMT_UNIT "i" +# define IDENT_AsType PyLong_AsUnsignedLong +#endif + +/* Unfortunately, we can't store python objects in udata, because + * kevents in the kernel can be removed without warning, which would + * forever lose the refcount on the object stored with it. + */ + +#define KQ_OFF(x) offsetof(kqueue_event_Object, x) +static struct PyMemberDef kqueue_event_members[] = { + {"ident", IDENT_TYPE, KQ_OFF(e.ident)}, + {"filter", T_SHORT, KQ_OFF(e.filter)}, + {"flags", T_USHORT, KQ_OFF(e.flags)}, + {"fflags", T_UINT, KQ_OFF(e.fflags)}, + {"data", DATA_TYPE, KQ_OFF(e.data)}, + {"udata", T_UINTPTRT, KQ_OFF(e.udata)}, + {NULL} /* Sentinel */ +}; +#undef KQ_OFF + +static PyObject * + +kqueue_event_repr(kqueue_event_Object *s) +{ + char buf[1024]; + PyOS_snprintf( + buf, sizeof(buf), + "", + (size_t)(s->e.ident), s->e.filter, s->e.flags, + s->e.fflags, (Py_ssize_t)(s->e.data), s->e.udata); + return PyUnicode_FromString(buf); +} + +static int +kqueue_event_init(kqueue_event_Object *self, PyObject *args, PyObject *kwds) +{ + PyObject *pfd; + static char *kwlist[] = {"ident", "filter", "flags", "fflags", + "data", "udata", NULL}; + static char *fmt = "O|hhi" DATA_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent"; + + EV_SET(&(self->e), 0, EVFILT_READ, EV_ADD, 0, 0, 0); /* defaults */ + + if (!PyArg_ParseTupleAndKeywords(args, kwds, fmt, kwlist, + &pfd, &(self->e.filter), &(self->e.flags), + &(self->e.fflags), &(self->e.data), &(self->e.udata))) { + return -1; + } + + if (PyLong_Check(pfd) +#if IDENT_TYPE == T_UINT + && PyLong_AsUnsignedLong(pfd) <= UINT_MAX +#endif + ) { + self->e.ident = IDENT_AsType(pfd); + } + else { + self->e.ident = PyObject_AsFileDescriptor(pfd); + } + if (PyErr_Occurred()) { + return -1; + } + return 0; +} + +static PyObject * +kqueue_event_richcompare(kqueue_event_Object *s, kqueue_event_Object *o, + int op) +{ + Py_intptr_t result = 0; + + if (!kqueue_event_Check(o)) { + if (op == Py_EQ || op == Py_NE) { + PyObject *res = op == Py_EQ ? Py_False : Py_True; + Py_INCREF(res); + return res; + } + PyErr_Format(PyExc_TypeError, + "can't compare %.200s to %.200s", + Py_TYPE(s)->tp_name, Py_TYPE(o)->tp_name); + return NULL; + } + if (((result = (IDENT_CAST)(s->e.ident - o->e.ident)) == 0) && + ((result = s->e.filter - o->e.filter) == 0) && + ((result = s->e.flags - o->e.flags) == 0) && + ((result = (int)(s->e.fflags - o->e.fflags)) == 0) && + ((result = s->e.data - o->e.data) == 0) && + ((result = s->e.udata - o->e.udata) == 0) + ) { + result = 0; + } + + switch (op) { + case Py_EQ: + result = (result == 0); + break; + case Py_NE: + result = (result != 0); + break; + case Py_LE: + result = (result <= 0); + break; + case Py_GE: + result = (result >= 0); + break; + case Py_LT: + result = (result < 0); + break; + case Py_GT: + result = (result > 0); + break; + } + return PyBool_FromLong((long)result); +} + +static PyTypeObject kqueue_event_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "select.kevent", /* tp_name */ + sizeof(kqueue_event_Object), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)kqueue_event_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + kqueue_event_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + (richcmpfunc)kqueue_event_richcompare, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + kqueue_event_members, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)kqueue_event_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ +}; + +static PyObject * +kqueue_queue_err_closed(void) +{ + PyErr_SetString(PyExc_ValueError, "I/O operation on closed kqueue fd"); + return NULL; +} + +static int +kqueue_queue_internal_close(kqueue_queue_Object *self) +{ + int save_errno = 0; + if (self->kqfd >= 0) { + int kqfd = self->kqfd; + self->kqfd = -1; + Py_BEGIN_ALLOW_THREADS + if (close(kqfd) < 0) + save_errno = errno; + Py_END_ALLOW_THREADS + } + return save_errno; +} + +static PyObject * +newKqueue_Object(PyTypeObject *type, SOCKET fd) +{ + kqueue_queue_Object *self; + assert(type != NULL && type->tp_alloc != NULL); + self = (kqueue_queue_Object *) type->tp_alloc(type, 0); + if (self == NULL) { + return NULL; + } + + if (fd == -1) { + Py_BEGIN_ALLOW_THREADS + self->kqfd = kqueue(); + Py_END_ALLOW_THREADS + } + else { + self->kqfd = fd; + } + if (self->kqfd < 0) { + Py_DECREF(self); + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + } + return (PyObject *)self; +} + +static PyObject * +kqueue_queue_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + + if ((args != NULL && PyObject_Size(args)) || + (kwds != NULL && PyObject_Size(kwds))) { + PyErr_SetString(PyExc_ValueError, + "select.kqueue doesn't accept arguments"); + return NULL; + } + + return newKqueue_Object(type, -1); +} + +static void +kqueue_queue_dealloc(kqueue_queue_Object *self) +{ + kqueue_queue_internal_close(self); + Py_TYPE(self)->tp_free(self); +} + +static PyObject* +kqueue_queue_close(kqueue_queue_Object *self) +{ + errno = kqueue_queue_internal_close(self); + if (errno < 0) { + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + } + Py_RETURN_NONE; +} + +PyDoc_STRVAR(kqueue_queue_close_doc, +"close() -> None\n\ +\n\ +Close the kqueue control file descriptor. Further operations on the kqueue\n\ +object will raise an exception."); + +static PyObject* +kqueue_queue_get_closed(kqueue_queue_Object *self) +{ + if (self->kqfd < 0) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +static PyObject* +kqueue_queue_fileno(kqueue_queue_Object *self) +{ + if (self->kqfd < 0) + return kqueue_queue_err_closed(); + return PyLong_FromLong(self->kqfd); +} + +PyDoc_STRVAR(kqueue_queue_fileno_doc, +"fileno() -> int\n\ +\n\ +Return the kqueue control file descriptor."); + +static PyObject* +kqueue_queue_fromfd(PyObject *cls, PyObject *args) +{ + SOCKET fd; + + if (!PyArg_ParseTuple(args, "i:fromfd", &fd)) + return NULL; + + return newKqueue_Object((PyTypeObject*)cls, fd); +} + +PyDoc_STRVAR(kqueue_queue_fromfd_doc, +"fromfd(fd) -> kqueue\n\ +\n\ +Create a kqueue object from a given control fd."); + +static PyObject * +kqueue_queue_control(kqueue_queue_Object *self, PyObject *args) +{ + int nevents = 0; + int gotevents = 0; + int nchanges = 0; + int i = 0; + PyObject *otimeout = NULL; + PyObject *ch = NULL; + PyObject *it = NULL, *ei = NULL; + PyObject *result = NULL; + struct kevent *evl = NULL; + struct kevent *chl = NULL; + struct timespec timeout; + struct timespec *ptimeoutspec; + + if (self->kqfd < 0) + return kqueue_queue_err_closed(); + + if (!PyArg_ParseTuple(args, "Oi|O:control", &ch, &nevents, &otimeout)) + return NULL; + + if (nevents < 0) { + PyErr_Format(PyExc_ValueError, + "Length of eventlist must be 0 or positive, got %d", + nevents); + return NULL; + } + + if (otimeout == Py_None || otimeout == NULL) { + ptimeoutspec = NULL; + } + else if (PyNumber_Check(otimeout)) { + if (_PyTime_ObjectToTimespec(otimeout, + &timeout.tv_sec, &timeout.tv_nsec) == -1) + return NULL; + + if (timeout.tv_sec < 0) { + PyErr_SetString(PyExc_ValueError, + "timeout must be positive or None"); + return NULL; + } + ptimeoutspec = &timeout; + } + else { + PyErr_Format(PyExc_TypeError, + "timeout argument must be an number " + "or None, got %.200s", + Py_TYPE(otimeout)->tp_name); + return NULL; + } + + if (ch != NULL && ch != Py_None) { + it = PyObject_GetIter(ch); + if (it == NULL) { + PyErr_SetString(PyExc_TypeError, + "changelist is not iterable"); + return NULL; + } + nchanges = PyObject_Size(ch); + if (nchanges < 0) { + goto error; + } + + chl = PyMem_New(struct kevent, nchanges); + if (chl == NULL) { + PyErr_NoMemory(); + goto error; + } + i = 0; + while ((ei = PyIter_Next(it)) != NULL) { + if (!kqueue_event_Check(ei)) { + Py_DECREF(ei); + PyErr_SetString(PyExc_TypeError, + "changelist must be an iterable of " + "select.kevent objects"); + goto error; + } else { + chl[i++] = ((kqueue_event_Object *)ei)->e; + } + Py_DECREF(ei); + } + } + Py_CLEAR(it); + + /* event list */ + if (nevents) { + evl = PyMem_New(struct kevent, nevents); + if (evl == NULL) { + PyErr_NoMemory(); + goto error; + } + } + + Py_BEGIN_ALLOW_THREADS + gotevents = kevent(self->kqfd, chl, nchanges, + evl, nevents, ptimeoutspec); + Py_END_ALLOW_THREADS + + if (gotevents == -1) { + PyErr_SetFromErrno(PyExc_OSError); + goto error; + } + + result = PyList_New(gotevents); + if (result == NULL) { + goto error; + } + + for (i = 0; i < gotevents; i++) { + kqueue_event_Object *ch; + + ch = PyObject_New(kqueue_event_Object, &kqueue_event_Type); + if (ch == NULL) { + goto error; + } + ch->e = evl[i]; + PyList_SET_ITEM(result, i, (PyObject *)ch); + } + PyMem_Free(chl); + PyMem_Free(evl); + return result; + + error: + PyMem_Free(chl); + PyMem_Free(evl); + Py_XDECREF(result); + Py_XDECREF(it); + return NULL; +} + +PyDoc_STRVAR(kqueue_queue_control_doc, +"control(changelist, max_events[, timeout=None]) -> eventlist\n\ +\n\ +Calls the kernel kevent function.\n\ +- changelist must be a list of kevent objects describing the changes\n\ + to be made to the kernel's watch list or None.\n\ +- max_events lets you specify the maximum number of events that the\n\ + kernel will return.\n\ +- timeout is the maximum time to wait in seconds, or else None,\n\ + to wait forever. timeout accepts floats for smaller timeouts, too."); + + +static PyMethodDef kqueue_queue_methods[] = { + {"fromfd", (PyCFunction)kqueue_queue_fromfd, + METH_VARARGS | METH_CLASS, kqueue_queue_fromfd_doc}, + {"close", (PyCFunction)kqueue_queue_close, METH_NOARGS, + kqueue_queue_close_doc}, + {"fileno", (PyCFunction)kqueue_queue_fileno, METH_NOARGS, + kqueue_queue_fileno_doc}, + {"control", (PyCFunction)kqueue_queue_control, + METH_VARARGS , kqueue_queue_control_doc}, + {NULL, NULL}, +}; + +static PyGetSetDef kqueue_queue_getsetlist[] = { + {"closed", (getter)kqueue_queue_get_closed, NULL, + "True if the kqueue handler is closed"}, + {0}, +}; + +PyDoc_STRVAR(kqueue_queue_doc, +"Kqueue syscall wrapper.\n\ +\n\ +For example, to start watching a socket for input:\n\ +>>> kq = kqueue()\n\ +>>> sock = socket()\n\ +>>> sock.connect((host, port))\n\ +>>> kq.control([kevent(sock, KQ_FILTER_WRITE, KQ_EV_ADD)], 0)\n\ +\n\ +To wait one second for it to become writeable:\n\ +>>> kq.control(None, 1, 1000)\n\ +\n\ +To stop listening:\n\ +>>> kq.control([kevent(sock, KQ_FILTER_WRITE, KQ_EV_DELETE)], 0)"); + +static PyTypeObject kqueue_queue_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "select.kqueue", /* tp_name */ + sizeof(kqueue_queue_Object), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)kqueue_queue_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + kqueue_queue_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + kqueue_queue_methods, /* tp_methods */ + 0, /* tp_members */ + kqueue_queue_getsetlist, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + kqueue_queue_new, /* tp_new */ + 0, /* tp_free */ +}; + +#endif /* HAVE_KQUEUE */ + + + + + +/* ************************************************************************ */ + +PyDoc_STRVAR(select_doc, +"select(rlist, wlist, xlist[, timeout]) -> (rlist, wlist, xlist)\n\ +\n\ +Wait until one or more file descriptors are ready for some kind of I/O.\n\ +The first three arguments are sequences of file descriptors to be waited for:\n\ +rlist -- wait until ready for reading\n\ +wlist -- wait until ready for writing\n\ +xlist -- wait for an ``exceptional condition''\n\ +If only one kind of condition is required, pass [] for the other lists.\n\ +A file descriptor is either a socket or file object, or a small integer\n\ +gotten from a fileno() method call on one of those.\n\ +\n\ +The optional 4th argument specifies a timeout in seconds; it may be\n\ +a floating point number to specify fractions of seconds. If it is absent\n\ +or None, the call will never time out.\n\ +\n\ +The return value is a tuple of three lists corresponding to the first three\n\ +arguments; each contains the subset of the corresponding file descriptors\n\ +that are ready.\n\ +\n\ +*** IMPORTANT NOTICE ***\n\ +On Windows and OpenVMS, only sockets are supported; on Unix, all file\n\ +descriptors can be used."); + +static PyMethodDef select_methods[] = { + {"select", select_select, METH_VARARGS, select_doc}, +#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) + {"poll", select_poll, METH_NOARGS, poll_doc}, +#endif /* HAVE_POLL */ +#ifdef HAVE_SYS_DEVPOLL_H + {"devpoll", select_devpoll, METH_NOARGS, devpoll_doc}, +#endif + {0, 0}, /* sentinel */ +}; + +PyDoc_STRVAR(module_doc, +"This module supports asynchronous I/O on multiple file descriptors.\n\ +\n\ +*** IMPORTANT NOTICE ***\n\ +On Windows and OpenVMS, only sockets are supported; on Unix, all file descriptors."); + + +static struct PyModuleDef selectmodule = { + PyModuleDef_HEAD_INIT, + "_select", + module_doc, + -1, + select_methods, + NULL, + NULL, + NULL, + NULL +}; + + + + +PyMODINIT_FUNC +PyInit__select(void) +{ + PyObject *m; + m = PyModule_Create(&selectmodule); + if (m == NULL) + return NULL; + + Py_INCREF(PyExc_OSError); + PyModule_AddObject(m, "error", PyExc_OSError); + +#ifdef PIPE_BUF +#ifdef HAVE_BROKEN_PIPE_BUF +#undef PIPE_BUF +#define PIPE_BUF 512 +#endif + PyModule_AddIntMacro(m, PIPE_BUF); +#endif + +#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) +#ifdef __APPLE__ + if (select_have_broken_poll()) { + if (PyObject_DelAttrString(m, "poll") == -1) { + PyErr_Clear(); + } + } else { +#else + { +#endif + if (PyType_Ready(&poll_Type) < 0) + return NULL; + PyModule_AddIntMacro(m, POLLIN); + PyModule_AddIntMacro(m, POLLPRI); + PyModule_AddIntMacro(m, POLLOUT); + PyModule_AddIntMacro(m, POLLERR); + PyModule_AddIntMacro(m, POLLHUP); + PyModule_AddIntMacro(m, POLLNVAL); + +#ifdef POLLRDNORM + PyModule_AddIntMacro(m, POLLRDNORM); +#endif +#ifdef POLLRDBAND + PyModule_AddIntMacro(m, POLLRDBAND); +#endif +#ifdef POLLWRNORM + PyModule_AddIntMacro(m, POLLWRNORM); +#endif +#ifdef POLLWRBAND + PyModule_AddIntMacro(m, POLLWRBAND); +#endif +#ifdef POLLMSG + PyModule_AddIntMacro(m, POLLMSG); +#endif + } +#endif /* HAVE_POLL */ + +#ifdef HAVE_SYS_DEVPOLL_H + if (PyType_Ready(&devpoll_Type) < 0) + return NULL; +#endif + +#ifdef HAVE_EPOLL + Py_TYPE(&pyEpoll_Type) = &PyType_Type; + if (PyType_Ready(&pyEpoll_Type) < 0) + return NULL; + + Py_INCREF(&pyEpoll_Type); + PyModule_AddObject(m, "epoll", (PyObject *) &pyEpoll_Type); + + PyModule_AddIntMacro(m, EPOLLIN); + PyModule_AddIntMacro(m, EPOLLOUT); + PyModule_AddIntMacro(m, EPOLLPRI); + PyModule_AddIntMacro(m, EPOLLERR); + PyModule_AddIntMacro(m, EPOLLHUP); + PyModule_AddIntMacro(m, EPOLLET); +#ifdef EPOLLONESHOT + /* Kernel 2.6.2+ */ + PyModule_AddIntMacro(m, EPOLLONESHOT); +#endif + /* PyModule_AddIntConstant(m, "EPOLL_RDHUP", EPOLLRDHUP); */ + PyModule_AddIntMacro(m, EPOLLRDNORM); + PyModule_AddIntMacro(m, EPOLLRDBAND); + PyModule_AddIntMacro(m, EPOLLWRNORM); + PyModule_AddIntMacro(m, EPOLLWRBAND); + PyModule_AddIntMacro(m, EPOLLMSG); + +#ifdef EPOLL_CLOEXEC + PyModule_AddIntMacro(m, EPOLL_CLOEXEC); +#endif +#endif /* HAVE_EPOLL */ + +#ifdef HAVE_KQUEUE + kqueue_event_Type.tp_new = PyType_GenericNew; + Py_TYPE(&kqueue_event_Type) = &PyType_Type; + if(PyType_Ready(&kqueue_event_Type) < 0) + return NULL; + + Py_INCREF(&kqueue_event_Type); + PyModule_AddObject(m, "kevent", (PyObject *)&kqueue_event_Type); + + Py_TYPE(&kqueue_queue_Type) = &PyType_Type; + if(PyType_Ready(&kqueue_queue_Type) < 0) + return NULL; + Py_INCREF(&kqueue_queue_Type); + PyModule_AddObject(m, "kqueue", (PyObject *)&kqueue_queue_Type); + + /* event filters */ + PyModule_AddIntConstant(m, "KQ_FILTER_READ", EVFILT_READ); + PyModule_AddIntConstant(m, "KQ_FILTER_WRITE", EVFILT_WRITE); + PyModule_AddIntConstant(m, "KQ_FILTER_AIO", EVFILT_AIO); + PyModule_AddIntConstant(m, "KQ_FILTER_VNODE", EVFILT_VNODE); + PyModule_AddIntConstant(m, "KQ_FILTER_PROC", EVFILT_PROC); +#ifdef EVFILT_NETDEV + PyModule_AddIntConstant(m, "KQ_FILTER_NETDEV", EVFILT_NETDEV); +#endif + PyModule_AddIntConstant(m, "KQ_FILTER_SIGNAL", EVFILT_SIGNAL); + PyModule_AddIntConstant(m, "KQ_FILTER_TIMER", EVFILT_TIMER); + + /* event flags */ + PyModule_AddIntConstant(m, "KQ_EV_ADD", EV_ADD); + PyModule_AddIntConstant(m, "KQ_EV_DELETE", EV_DELETE); + PyModule_AddIntConstant(m, "KQ_EV_ENABLE", EV_ENABLE); + PyModule_AddIntConstant(m, "KQ_EV_DISABLE", EV_DISABLE); + PyModule_AddIntConstant(m, "KQ_EV_ONESHOT", EV_ONESHOT); + PyModule_AddIntConstant(m, "KQ_EV_CLEAR", EV_CLEAR); + + PyModule_AddIntConstant(m, "KQ_EV_SYSFLAGS", EV_SYSFLAGS); + PyModule_AddIntConstant(m, "KQ_EV_FLAG1", EV_FLAG1); + + PyModule_AddIntConstant(m, "KQ_EV_EOF", EV_EOF); + PyModule_AddIntConstant(m, "KQ_EV_ERROR", EV_ERROR); + + /* READ WRITE filter flag */ + PyModule_AddIntConstant(m, "KQ_NOTE_LOWAT", NOTE_LOWAT); + + /* VNODE filter flags */ + PyModule_AddIntConstant(m, "KQ_NOTE_DELETE", NOTE_DELETE); + PyModule_AddIntConstant(m, "KQ_NOTE_WRITE", NOTE_WRITE); + PyModule_AddIntConstant(m, "KQ_NOTE_EXTEND", NOTE_EXTEND); + PyModule_AddIntConstant(m, "KQ_NOTE_ATTRIB", NOTE_ATTRIB); + PyModule_AddIntConstant(m, "KQ_NOTE_LINK", NOTE_LINK); + PyModule_AddIntConstant(m, "KQ_NOTE_RENAME", NOTE_RENAME); + PyModule_AddIntConstant(m, "KQ_NOTE_REVOKE", NOTE_REVOKE); + + /* PROC filter flags */ + PyModule_AddIntConstant(m, "KQ_NOTE_EXIT", NOTE_EXIT); + PyModule_AddIntConstant(m, "KQ_NOTE_FORK", NOTE_FORK); + PyModule_AddIntConstant(m, "KQ_NOTE_EXEC", NOTE_EXEC); + PyModule_AddIntConstant(m, "KQ_NOTE_PCTRLMASK", NOTE_PCTRLMASK); + PyModule_AddIntConstant(m, "KQ_NOTE_PDATAMASK", NOTE_PDATAMASK); + + PyModule_AddIntConstant(m, "KQ_NOTE_TRACK", NOTE_TRACK); + PyModule_AddIntConstant(m, "KQ_NOTE_CHILD", NOTE_CHILD); + PyModule_AddIntConstant(m, "KQ_NOTE_TRACKERR", NOTE_TRACKERR); + + /* NETDEV filter flags */ +#ifdef EVFILT_NETDEV + PyModule_AddIntConstant(m, "KQ_NOTE_LINKUP", NOTE_LINKUP); + PyModule_AddIntConstant(m, "KQ_NOTE_LINKDOWN", NOTE_LINKDOWN); + PyModule_AddIntConstant(m, "KQ_NOTE_LINKINV", NOTE_LINKINV); +#endif + +#endif /* HAVE_KQUEUE */ + return m; +} diff -r 1287d4c9cd39 Modules/selectmodule.c --- a/Modules/selectmodule.c Fri Aug 02 10:22:07 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2334 +0,0 @@ -/* select - Module containing unix select(2) call. - Under Unix, the file descriptors are small integers. - Under Win32, select only exists for sockets, and sockets may - have any value except INVALID_SOCKET. -*/ - -#include "Python.h" -#include - -#ifdef HAVE_SYS_DEVPOLL_H -#include -#include -#include -#include -#include -#endif - -#ifdef __APPLE__ - /* Perform runtime testing for a broken poll on OSX to make it easier - * to use the same binary on multiple releases of the OS. - */ -#undef HAVE_BROKEN_POLL -#endif - -/* Windows #defines FD_SETSIZE to 64 if FD_SETSIZE isn't already defined. - 64 is too small (too many people have bumped into that limit). - Here we boost it. - Users who want even more than the boosted limit should #define - FD_SETSIZE higher before this; e.g., via compiler /D switch. -*/ -#if defined(MS_WINDOWS) && !defined(FD_SETSIZE) -#define FD_SETSIZE 512 -#endif - -#if defined(HAVE_POLL_H) -#include -#elif defined(HAVE_SYS_POLL_H) -#include -#endif - -#ifdef __sgi -/* This is missing from unistd.h */ -extern void bzero(void *, int); -#endif - -#ifdef HAVE_SYS_TYPES_H -#include -#endif - -#ifdef MS_WINDOWS -# define WIN32_LEAN_AND_MEAN -# include -#else -# define SOCKET int -# if defined(__VMS) -# include -# endif -#endif - -/* list of Python objects and their file descriptor */ -typedef struct { - PyObject *obj; /* owned reference */ - SOCKET fd; - int sentinel; /* -1 == sentinel */ -} pylist; - -static void -reap_obj(pylist fd2obj[FD_SETSIZE + 1]) -{ - int i; - for (i = 0; i < FD_SETSIZE + 1 && fd2obj[i].sentinel >= 0; i++) { - Py_XDECREF(fd2obj[i].obj); - fd2obj[i].obj = NULL; - } - fd2obj[0].sentinel = -1; -} - - -/* returns -1 and sets the Python exception if an error occurred, otherwise - returns a number >= 0 -*/ -static int -seq2set(PyObject *seq, fd_set *set, pylist fd2obj[FD_SETSIZE + 1]) -{ - int max = -1; - int index = 0; - Py_ssize_t i; - PyObject* fast_seq = NULL; - PyObject* o = NULL; - - fd2obj[0].obj = (PyObject*)0; /* set list to zero size */ - FD_ZERO(set); - - fast_seq = PySequence_Fast(seq, "arguments 1-3 must be sequences"); - if (!fast_seq) - return -1; - - for (i = 0; i < PySequence_Fast_GET_SIZE(fast_seq); i++) { - SOCKET v; - - /* any intervening fileno() calls could decr this refcnt */ - if (!(o = PySequence_Fast_GET_ITEM(fast_seq, i))) - goto finally; - - Py_INCREF(o); - v = PyObject_AsFileDescriptor( o ); - if (v == -1) goto finally; - -#if defined(_MSC_VER) - max = 0; /* not used for Win32 */ -#else /* !_MSC_VER */ - if (!_PyIsSelectable_fd(v)) { - PyErr_SetString(PyExc_ValueError, - "filedescriptor out of range in select()"); - goto finally; - } - if (v > max) - max = v; -#endif /* _MSC_VER */ - FD_SET(v, set); - - /* add object and its file descriptor to the list */ - if (index >= FD_SETSIZE) { - PyErr_SetString(PyExc_ValueError, - "too many file descriptors in select()"); - goto finally; - } - fd2obj[index].obj = o; - fd2obj[index].fd = v; - fd2obj[index].sentinel = 0; - fd2obj[++index].sentinel = -1; - } - Py_DECREF(fast_seq); - return max+1; - - finally: - Py_XDECREF(o); - Py_DECREF(fast_seq); - return -1; -} - -/* returns NULL and sets the Python exception if an error occurred */ -static PyObject * -set2list(fd_set *set, pylist fd2obj[FD_SETSIZE + 1]) -{ - int i, j, count=0; - PyObject *list, *o; - SOCKET fd; - - for (j = 0; fd2obj[j].sentinel >= 0; j++) { - if (FD_ISSET(fd2obj[j].fd, set)) - count++; - } - list = PyList_New(count); - if (!list) - return NULL; - - i = 0; - for (j = 0; fd2obj[j].sentinel >= 0; j++) { - fd = fd2obj[j].fd; - if (FD_ISSET(fd, set)) { - o = fd2obj[j].obj; - fd2obj[j].obj = NULL; - /* transfer ownership */ - if (PyList_SetItem(list, i, o) < 0) - goto finally; - - i++; - } - } - return list; - finally: - Py_DECREF(list); - return NULL; -} - -#undef SELECT_USES_HEAP -#if FD_SETSIZE > 1024 -#define SELECT_USES_HEAP -#endif /* FD_SETSIZE > 1024 */ - -static PyObject * -select_select(PyObject *self, PyObject *args) -{ -#ifdef SELECT_USES_HEAP - pylist *rfd2obj, *wfd2obj, *efd2obj; -#else /* !SELECT_USES_HEAP */ - /* XXX: All this should probably be implemented as follows: - * - find the highest descriptor we're interested in - * - add one - * - that's the size - * See: Stevens, APitUE, $12.5.1 - */ - pylist rfd2obj[FD_SETSIZE + 1]; - pylist wfd2obj[FD_SETSIZE + 1]; - pylist efd2obj[FD_SETSIZE + 1]; -#endif /* SELECT_USES_HEAP */ - PyObject *ifdlist, *ofdlist, *efdlist; - PyObject *ret = NULL; - PyObject *tout = Py_None; - fd_set ifdset, ofdset, efdset; - struct timeval tv, *tvp; - int imax, omax, emax, max; - int n; - - /* convert arguments */ - if (!PyArg_UnpackTuple(args, "select", 3, 4, - &ifdlist, &ofdlist, &efdlist, &tout)) - return NULL; - - if (tout == Py_None) - tvp = (struct timeval *)0; - else if (!PyNumber_Check(tout)) { - PyErr_SetString(PyExc_TypeError, - "timeout must be a float or None"); - return NULL; - } - else { -#ifdef MS_WINDOWS - time_t sec; - if (_PyTime_ObjectToTimeval(tout, &sec, &tv.tv_usec) == -1) - return NULL; - assert(sizeof(tv.tv_sec) == sizeof(long)); -#if SIZEOF_TIME_T > SIZEOF_LONG - if (sec > LONG_MAX) { - PyErr_SetString(PyExc_OverflowError, - "timeout is too large"); - return NULL; - } -#endif - tv.tv_sec = (long)sec; -#else - /* 64-bit OS X has struct timeval.tv_usec as an int (and thus still 4 - bytes as required), but no longer defined by a long. */ - long tv_usec; - if (_PyTime_ObjectToTimeval(tout, &tv.tv_sec, &tv_usec) == -1) - return NULL; - tv.tv_usec = tv_usec; -#endif - if (tv.tv_sec < 0) { - PyErr_SetString(PyExc_ValueError, "timeout must be non-negative"); - return NULL; - } - tvp = &tv; - } - - -#ifdef SELECT_USES_HEAP - /* Allocate memory for the lists */ - rfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1); - wfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1); - efd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1); - if (rfd2obj == NULL || wfd2obj == NULL || efd2obj == NULL) { - if (rfd2obj) PyMem_DEL(rfd2obj); - if (wfd2obj) PyMem_DEL(wfd2obj); - if (efd2obj) PyMem_DEL(efd2obj); - return PyErr_NoMemory(); - } -#endif /* SELECT_USES_HEAP */ - /* Convert sequences to fd_sets, and get maximum fd number - * propagates the Python exception set in seq2set() - */ - rfd2obj[0].sentinel = -1; - wfd2obj[0].sentinel = -1; - efd2obj[0].sentinel = -1; - if ((imax=seq2set(ifdlist, &ifdset, rfd2obj)) < 0) - goto finally; - if ((omax=seq2set(ofdlist, &ofdset, wfd2obj)) < 0) - goto finally; - if ((emax=seq2set(efdlist, &efdset, efd2obj)) < 0) - goto finally; - max = imax; - if (omax > max) max = omax; - if (emax > max) max = emax; - - Py_BEGIN_ALLOW_THREADS - n = select(max, &ifdset, &ofdset, &efdset, tvp); - Py_END_ALLOW_THREADS - -#ifdef MS_WINDOWS - if (n == SOCKET_ERROR) { - PyErr_SetExcFromWindowsErr(PyExc_OSError, WSAGetLastError()); - } -#else - if (n < 0) { - PyErr_SetFromErrno(PyExc_OSError); - } -#endif - else { - /* any of these three calls can raise an exception. it's more - convenient to test for this after all three calls... but - is that acceptable? - */ - ifdlist = set2list(&ifdset, rfd2obj); - ofdlist = set2list(&ofdset, wfd2obj); - efdlist = set2list(&efdset, efd2obj); - if (PyErr_Occurred()) - ret = NULL; - else - ret = PyTuple_Pack(3, ifdlist, ofdlist, efdlist); - - Py_XDECREF(ifdlist); - Py_XDECREF(ofdlist); - Py_XDECREF(efdlist); - } - - finally: - reap_obj(rfd2obj); - reap_obj(wfd2obj); - reap_obj(efd2obj); -#ifdef SELECT_USES_HEAP - PyMem_DEL(rfd2obj); - PyMem_DEL(wfd2obj); - PyMem_DEL(efd2obj); -#endif /* SELECT_USES_HEAP */ - return ret; -} - -#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) -/* - * poll() support - */ - -typedef struct { - PyObject_HEAD - PyObject *dict; - int ufd_uptodate; - int ufd_len; - struct pollfd *ufds; -} pollObject; - -static PyTypeObject poll_Type; - -/* Update the malloc'ed array of pollfds to match the dictionary - contained within a pollObject. Return 1 on success, 0 on an error. -*/ - -static int -update_ufd_array(pollObject *self) -{ - Py_ssize_t i, pos; - PyObject *key, *value; - struct pollfd *old_ufds = self->ufds; - - self->ufd_len = PyDict_Size(self->dict); - PyMem_RESIZE(self->ufds, struct pollfd, self->ufd_len); - if (self->ufds == NULL) { - self->ufds = old_ufds; - PyErr_NoMemory(); - return 0; - } - - i = pos = 0; - while (PyDict_Next(self->dict, &pos, &key, &value)) { - assert(i < self->ufd_len); - /* Never overflow */ - self->ufds[i].fd = (int)PyLong_AsLong(key); - self->ufds[i].events = (short)PyLong_AsLong(value); - i++; - } - assert(i == self->ufd_len); - self->ufd_uptodate = 1; - return 1; -} - -PyDoc_STRVAR(poll_register_doc, -"register(fd [, eventmask] ) -> None\n\n\ -Register a file descriptor with the polling object.\n\ -fd -- either an integer, or an object with a fileno() method returning an\n\ - int.\n\ -events -- an optional bitmask describing the type of events to check for"); - -static PyObject * -poll_register(pollObject *self, PyObject *args) -{ - PyObject *o, *key, *value; - int fd; - short events = POLLIN | POLLPRI | POLLOUT; - int err; - - if (!PyArg_ParseTuple(args, "O|h:register", &o, &events)) { - return NULL; - } - - fd = PyObject_AsFileDescriptor(o); - if (fd == -1) return NULL; - - /* Add entry to the internal dictionary: the key is the - file descriptor, and the value is the event mask. */ - key = PyLong_FromLong(fd); - if (key == NULL) - return NULL; - value = PyLong_FromLong(events); - if (value == NULL) { - Py_DECREF(key); - return NULL; - } - err = PyDict_SetItem(self->dict, key, value); - Py_DECREF(key); - Py_DECREF(value); - if (err < 0) - return NULL; - - self->ufd_uptodate = 0; - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(poll_modify_doc, -"modify(fd, eventmask) -> None\n\n\ -Modify an already registered file descriptor.\n\ -fd -- either an integer, or an object with a fileno() method returning an\n\ - int.\n\ -events -- an optional bitmask describing the type of events to check for"); - -static PyObject * -poll_modify(pollObject *self, PyObject *args) -{ - PyObject *o, *key, *value; - int fd, events; - int err; - - if (!PyArg_ParseTuple(args, "Oi:modify", &o, &events)) { - return NULL; - } - - fd = PyObject_AsFileDescriptor(o); - if (fd == -1) return NULL; - - /* Modify registered fd */ - key = PyLong_FromLong(fd); - if (key == NULL) - return NULL; - if (PyDict_GetItem(self->dict, key) == NULL) { - errno = ENOENT; - PyErr_SetFromErrno(PyExc_OSError); - Py_DECREF(key); - return NULL; - } - value = PyLong_FromLong(events); - if (value == NULL) { - Py_DECREF(key); - return NULL; - } - err = PyDict_SetItem(self->dict, key, value); - Py_DECREF(key); - Py_DECREF(value); - if (err < 0) - return NULL; - - self->ufd_uptodate = 0; - - Py_INCREF(Py_None); - return Py_None; -} - - -PyDoc_STRVAR(poll_unregister_doc, -"unregister(fd) -> None\n\n\ -Remove a file descriptor being tracked by the polling object."); - -static PyObject * -poll_unregister(pollObject *self, PyObject *o) -{ - PyObject *key; - int fd; - - fd = PyObject_AsFileDescriptor( o ); - if (fd == -1) - return NULL; - - /* Check whether the fd is already in the array */ - key = PyLong_FromLong(fd); - if (key == NULL) - return NULL; - - if (PyDict_DelItem(self->dict, key) == -1) { - Py_DECREF(key); - /* This will simply raise the KeyError set by PyDict_DelItem - if the file descriptor isn't registered. */ - return NULL; - } - - Py_DECREF(key); - self->ufd_uptodate = 0; - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(poll_poll_doc, -"poll( [timeout] ) -> list of (fd, event) 2-tuples\n\n\ -Polls the set of registered file descriptors, returning a list containing \n\ -any descriptors that have events or errors to report."); - -static PyObject * -poll_poll(pollObject *self, PyObject *args) -{ - PyObject *result_list = NULL, *tout = NULL; - int timeout = 0, poll_result, i, j; - PyObject *value = NULL, *num = NULL; - - if (!PyArg_UnpackTuple(args, "poll", 0, 1, &tout)) { - return NULL; - } - - /* Check values for timeout */ - if (tout == NULL || tout == Py_None) - timeout = -1; - else if (!PyNumber_Check(tout)) { - PyErr_SetString(PyExc_TypeError, - "timeout must be an integer or None"); - return NULL; - } - else { - tout = PyNumber_Long(tout); - if (!tout) - return NULL; - timeout = _PyLong_AsInt(tout); - Py_DECREF(tout); - if (timeout == -1 && PyErr_Occurred()) - return NULL; - } - - /* Ensure the ufd array is up to date */ - if (!self->ufd_uptodate) - if (update_ufd_array(self) == 0) - return NULL; - - /* call poll() */ - Py_BEGIN_ALLOW_THREADS - poll_result = poll(self->ufds, self->ufd_len, timeout); - Py_END_ALLOW_THREADS - - if (poll_result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } - - /* build the result list */ - - result_list = PyList_New(poll_result); - if (!result_list) - return NULL; - else { - for (i = 0, j = 0; j < poll_result; j++) { - /* skip to the next fired descriptor */ - while (!self->ufds[i].revents) { - i++; - } - /* if we hit a NULL return, set value to NULL - and break out of loop; code at end will - clean up result_list */ - value = PyTuple_New(2); - if (value == NULL) - goto error; - num = PyLong_FromLong(self->ufds[i].fd); - if (num == NULL) { - Py_DECREF(value); - goto error; - } - PyTuple_SET_ITEM(value, 0, num); - - /* The &0xffff is a workaround for AIX. 'revents' - is a 16-bit short, and IBM assigned POLLNVAL - to be 0x8000, so the conversion to int results - in a negative number. See SF bug #923315. */ - num = PyLong_FromLong(self->ufds[i].revents & 0xffff); - if (num == NULL) { - Py_DECREF(value); - goto error; - } - PyTuple_SET_ITEM(value, 1, num); - if ((PyList_SetItem(result_list, j, value)) == -1) { - Py_DECREF(value); - goto error; - } - i++; - } - } - return result_list; - - error: - Py_DECREF(result_list); - return NULL; -} - -static PyMethodDef poll_methods[] = { - {"register", (PyCFunction)poll_register, - METH_VARARGS, poll_register_doc}, - {"modify", (PyCFunction)poll_modify, - METH_VARARGS, poll_modify_doc}, - {"unregister", (PyCFunction)poll_unregister, - METH_O, poll_unregister_doc}, - {"poll", (PyCFunction)poll_poll, - METH_VARARGS, poll_poll_doc}, - {NULL, NULL} /* sentinel */ -}; - -static pollObject * -newPollObject(void) -{ - pollObject *self; - self = PyObject_New(pollObject, &poll_Type); - if (self == NULL) - return NULL; - /* ufd_uptodate is a Boolean, denoting whether the - array pointed to by ufds matches the contents of the dictionary. */ - self->ufd_uptodate = 0; - self->ufds = NULL; - self->dict = PyDict_New(); - if (self->dict == NULL) { - Py_DECREF(self); - return NULL; - } - return self; -} - -static void -poll_dealloc(pollObject *self) -{ - if (self->ufds != NULL) - PyMem_DEL(self->ufds); - Py_XDECREF(self->dict); - PyObject_Del(self); -} - -static PyTypeObject poll_Type = { - /* The ob_type field must be initialized in the module init function - * to be portable to Windows without using C++. */ - PyVarObject_HEAD_INIT(NULL, 0) - "select.poll", /*tp_name*/ - sizeof(pollObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)poll_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_reserved*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - poll_methods, /*tp_methods*/ -}; - -#ifdef HAVE_SYS_DEVPOLL_H -typedef struct { - PyObject_HEAD - int fd_devpoll; - int max_n_fds; - int n_fds; - struct pollfd *fds; -} devpollObject; - -static PyTypeObject devpoll_Type; - -static int devpoll_flush(devpollObject *self) -{ - int size, n; - - if (!self->n_fds) return 0; - - size = sizeof(struct pollfd)*self->n_fds; - self->n_fds = 0; - - Py_BEGIN_ALLOW_THREADS - n = write(self->fd_devpoll, self->fds, size); - Py_END_ALLOW_THREADS - - if (n == -1 ) { - PyErr_SetFromErrno(PyExc_IOError); - return -1; - } - if (n < size) { - /* - ** Data writed to /dev/poll is a binary data structure. It is not - ** clear what to do if a partial write occurred. For now, raise - ** an exception and see if we actually found this problem in - ** the wild. - ** See http://bugs.python.org/issue6397. - */ - PyErr_Format(PyExc_IOError, "failed to write all pollfds. " - "Please, report at http://bugs.python.org/. " - "Data to report: Size tried: %d, actual size written: %d.", - size, n); - return -1; - } - return 0; -} - -static PyObject * -internal_devpoll_register(devpollObject *self, PyObject *args, int remove) -{ - PyObject *o; - int fd, events = POLLIN | POLLPRI | POLLOUT; - - if (!PyArg_ParseTuple(args, "O|i:register", &o, &events)) { - return NULL; - } - - fd = PyObject_AsFileDescriptor(o); - if (fd == -1) return NULL; - - if (remove) { - self->fds[self->n_fds].fd = fd; - self->fds[self->n_fds].events = POLLREMOVE; - - if (++self->n_fds == self->max_n_fds) { - if (devpoll_flush(self)) - return NULL; - } - } - - self->fds[self->n_fds].fd = fd; - self->fds[self->n_fds].events = events; - - if (++self->n_fds == self->max_n_fds) { - if (devpoll_flush(self)) - return NULL; - } - - Py_RETURN_NONE; -} - -PyDoc_STRVAR(devpoll_register_doc, -"register(fd [, eventmask] ) -> None\n\n\ -Register a file descriptor with the polling object.\n\ -fd -- either an integer, or an object with a fileno() method returning an\n\ - int.\n\ -events -- an optional bitmask describing the type of events to check for"); - -static PyObject * -devpoll_register(devpollObject *self, PyObject *args) -{ - return internal_devpoll_register(self, args, 0); -} - -PyDoc_STRVAR(devpoll_modify_doc, -"modify(fd[, eventmask]) -> None\n\n\ -Modify a possible already registered file descriptor.\n\ -fd -- either an integer, or an object with a fileno() method returning an\n\ - int.\n\ -events -- an optional bitmask describing the type of events to check for"); - -static PyObject * -devpoll_modify(devpollObject *self, PyObject *args) -{ - return internal_devpoll_register(self, args, 1); -} - - -PyDoc_STRVAR(devpoll_unregister_doc, -"unregister(fd) -> None\n\n\ -Remove a file descriptor being tracked by the polling object."); - -static PyObject * -devpoll_unregister(devpollObject *self, PyObject *o) -{ - int fd; - - fd = PyObject_AsFileDescriptor( o ); - if (fd == -1) - return NULL; - - self->fds[self->n_fds].fd = fd; - self->fds[self->n_fds].events = POLLREMOVE; - - if (++self->n_fds == self->max_n_fds) { - if (devpoll_flush(self)) - return NULL; - } - - Py_RETURN_NONE; -} - -PyDoc_STRVAR(devpoll_poll_doc, -"poll( [timeout] ) -> list of (fd, event) 2-tuples\n\n\ -Polls the set of registered file descriptors, returning a list containing \n\ -any descriptors that have events or errors to report."); - -static PyObject * -devpoll_poll(devpollObject *self, PyObject *args) -{ - struct dvpoll dvp; - PyObject *result_list = NULL, *tout = NULL; - int poll_result, i; - long timeout; - PyObject *value, *num1, *num2; - - if (!PyArg_UnpackTuple(args, "poll", 0, 1, &tout)) { - return NULL; - } - - /* Check values for timeout */ - if (tout == NULL || tout == Py_None) - timeout = -1; - else if (!PyNumber_Check(tout)) { - PyErr_SetString(PyExc_TypeError, - "timeout must be an integer or None"); - return NULL; - } - else { - tout = PyNumber_Long(tout); - if (!tout) - return NULL; - timeout = PyLong_AsLong(tout); - Py_DECREF(tout); - if (timeout == -1 && PyErr_Occurred()) - return NULL; - } - - if ((timeout < -1) || (timeout > INT_MAX)) { - PyErr_SetString(PyExc_OverflowError, - "timeout is out of range"); - return NULL; - } - - if (devpoll_flush(self)) - return NULL; - - dvp.dp_fds = self->fds; - dvp.dp_nfds = self->max_n_fds; - dvp.dp_timeout = timeout; - - /* call devpoll() */ - Py_BEGIN_ALLOW_THREADS - poll_result = ioctl(self->fd_devpoll, DP_POLL, &dvp); - Py_END_ALLOW_THREADS - - if (poll_result < 0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - - /* build the result list */ - - result_list = PyList_New(poll_result); - if (!result_list) - return NULL; - else { - for (i = 0; i < poll_result; i++) { - num1 = PyLong_FromLong(self->fds[i].fd); - num2 = PyLong_FromLong(self->fds[i].revents); - if ((num1 == NULL) || (num2 == NULL)) { - Py_XDECREF(num1); - Py_XDECREF(num2); - goto error; - } - value = PyTuple_Pack(2, num1, num2); - Py_DECREF(num1); - Py_DECREF(num2); - if (value == NULL) - goto error; - if ((PyList_SetItem(result_list, i, value)) == -1) { - Py_DECREF(value); - goto error; - } - } - } - - return result_list; - - error: - Py_DECREF(result_list); - return NULL; -} - -static PyMethodDef devpoll_methods[] = { - {"register", (PyCFunction)devpoll_register, - METH_VARARGS, devpoll_register_doc}, - {"modify", (PyCFunction)devpoll_modify, - METH_VARARGS, devpoll_modify_doc}, - {"unregister", (PyCFunction)devpoll_unregister, - METH_O, devpoll_unregister_doc}, - {"poll", (PyCFunction)devpoll_poll, - METH_VARARGS, devpoll_poll_doc}, - {NULL, NULL} /* sentinel */ -}; - -static devpollObject * -newDevPollObject(void) -{ - devpollObject *self; - int fd_devpoll, limit_result; - struct pollfd *fds; - struct rlimit limit; - - Py_BEGIN_ALLOW_THREADS - /* - ** If we try to process more that getrlimit() - ** fds, the kernel will give an error, so - ** we set the limit here. It is a dynamic - ** value, because we can change rlimit() anytime. - */ - limit_result = getrlimit(RLIMIT_NOFILE, &limit); - if (limit_result != -1) - fd_devpoll = open("/dev/poll", O_RDWR); - Py_END_ALLOW_THREADS - - if (limit_result == -1) { - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } - if (fd_devpoll == -1) { - PyErr_SetFromErrnoWithFilename(PyExc_IOError, "/dev/poll"); - return NULL; - } - - fds = PyMem_NEW(struct pollfd, limit.rlim_cur); - if (fds == NULL) { - close(fd_devpoll); - PyErr_NoMemory(); - return NULL; - } - - self = PyObject_New(devpollObject, &devpoll_Type); - if (self == NULL) { - close(fd_devpoll); - PyMem_DEL(fds); - return NULL; - } - self->fd_devpoll = fd_devpoll; - self->max_n_fds = limit.rlim_cur; - self->n_fds = 0; - self->fds = fds; - - return self; -} - -static void -devpoll_dealloc(devpollObject *self) -{ - Py_BEGIN_ALLOW_THREADS - close(self->fd_devpoll); - Py_END_ALLOW_THREADS - - PyMem_DEL(self->fds); - - PyObject_Del(self); -} - -static PyTypeObject devpoll_Type = { - /* The ob_type field must be initialized in the module init function - * to be portable to Windows without using C++. */ - PyVarObject_HEAD_INIT(NULL, 0) - "select.devpoll", /*tp_name*/ - sizeof(devpollObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)devpoll_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_reserved*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - devpoll_methods, /*tp_methods*/ -}; -#endif /* HAVE_SYS_DEVPOLL_H */ - - - -PyDoc_STRVAR(poll_doc, -"Returns a polling object, which supports registering and\n\ -unregistering file descriptors, and then polling them for I/O events."); - -static PyObject * -select_poll(PyObject *self, PyObject *unused) -{ - return (PyObject *)newPollObject(); -} - -#ifdef HAVE_SYS_DEVPOLL_H -PyDoc_STRVAR(devpoll_doc, -"Returns a polling object, which supports registering and\n\ -unregistering file descriptors, and then polling them for I/O events."); - -static PyObject * -select_devpoll(PyObject *self, PyObject *unused) -{ - return (PyObject *)newDevPollObject(); -} -#endif - - -#ifdef __APPLE__ -/* - * On some systems poll() sets errno on invalid file descriptors. We test - * for this at runtime because this bug may be fixed or introduced between - * OS releases. - */ -static int select_have_broken_poll(void) -{ - int poll_test; - int filedes[2]; - - struct pollfd poll_struct = { 0, POLLIN|POLLPRI|POLLOUT, 0 }; - - /* Create a file descriptor to make invalid */ - if (pipe(filedes) < 0) { - return 1; - } - poll_struct.fd = filedes[0]; - close(filedes[0]); - close(filedes[1]); - poll_test = poll(&poll_struct, 1, 0); - if (poll_test < 0) { - return 1; - } else if (poll_test == 0 && poll_struct.revents != POLLNVAL) { - return 1; - } - return 0; -} -#endif /* __APPLE__ */ - -#endif /* HAVE_POLL */ - -#ifdef HAVE_EPOLL -/* ************************************************************************** - * epoll interface for Linux 2.6 - * - * Written by Christian Heimes - * Inspired by Twisted's _epoll.pyx and select.poll() - */ - -#ifdef HAVE_SYS_EPOLL_H -#include -#endif - -typedef struct { - PyObject_HEAD - SOCKET epfd; /* epoll control file descriptor */ -} pyEpoll_Object; - -static PyTypeObject pyEpoll_Type; -#define pyepoll_CHECK(op) (PyObject_TypeCheck((op), &pyEpoll_Type)) - -static PyObject * -pyepoll_err_closed(void) -{ - PyErr_SetString(PyExc_ValueError, "I/O operation on closed epoll fd"); - return NULL; -} - -static int -pyepoll_internal_close(pyEpoll_Object *self) -{ - int save_errno = 0; - if (self->epfd >= 0) { - int epfd = self->epfd; - self->epfd = -1; - Py_BEGIN_ALLOW_THREADS - if (close(epfd) < 0) - save_errno = errno; - Py_END_ALLOW_THREADS - } - return save_errno; -} - -static PyObject * -newPyEpoll_Object(PyTypeObject *type, int sizehint, int flags, SOCKET fd) -{ - pyEpoll_Object *self; - - assert(type != NULL && type->tp_alloc != NULL); - self = (pyEpoll_Object *) type->tp_alloc(type, 0); - if (self == NULL) - return NULL; - - if (fd == -1) { - Py_BEGIN_ALLOW_THREADS -#ifdef HAVE_EPOLL_CREATE1 - if (flags) - self->epfd = epoll_create1(flags); - else -#endif - self->epfd = epoll_create(sizehint); - Py_END_ALLOW_THREADS - } - else { - self->epfd = fd; - } - if (self->epfd < 0) { - Py_DECREF(self); - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } - return (PyObject *)self; -} - - -static PyObject * -pyepoll_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - int flags = 0, sizehint = FD_SETSIZE - 1; - static char *kwlist[] = {"sizehint", "flags", NULL}; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|ii:epoll", kwlist, - &sizehint, &flags)) - return NULL; - if (sizehint < 0) { - PyErr_SetString(PyExc_ValueError, "negative sizehint"); - return NULL; - } - - return newPyEpoll_Object(type, sizehint, flags, -1); -} - - -static void -pyepoll_dealloc(pyEpoll_Object *self) -{ - (void)pyepoll_internal_close(self); - Py_TYPE(self)->tp_free(self); -} - -static PyObject* -pyepoll_close(pyEpoll_Object *self) -{ - errno = pyepoll_internal_close(self); - if (errno < 0) { - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } - Py_RETURN_NONE; -} - -PyDoc_STRVAR(pyepoll_close_doc, -"close() -> None\n\ -\n\ -Close the epoll control file descriptor. Further operations on the epoll\n\ -object will raise an exception."); - -static PyObject* -pyepoll_get_closed(pyEpoll_Object *self) -{ - if (self->epfd < 0) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyObject* -pyepoll_fileno(pyEpoll_Object *self) -{ - if (self->epfd < 0) - return pyepoll_err_closed(); - return PyLong_FromLong(self->epfd); -} - -PyDoc_STRVAR(pyepoll_fileno_doc, -"fileno() -> int\n\ -\n\ -Return the epoll control file descriptor."); - -static PyObject* -pyepoll_fromfd(PyObject *cls, PyObject *args) -{ - SOCKET fd; - - if (!PyArg_ParseTuple(args, "i:fromfd", &fd)) - return NULL; - - return newPyEpoll_Object((PyTypeObject*)cls, FD_SETSIZE - 1, 0, fd); -} - -PyDoc_STRVAR(pyepoll_fromfd_doc, -"fromfd(fd) -> epoll\n\ -\n\ -Create an epoll object from a given control fd."); - -static PyObject * -pyepoll_internal_ctl(int epfd, int op, PyObject *pfd, unsigned int events) -{ - struct epoll_event ev; - int result; - int fd; - - if (epfd < 0) - return pyepoll_err_closed(); - - fd = PyObject_AsFileDescriptor(pfd); - if (fd == -1) { - return NULL; - } - - switch(op) { - case EPOLL_CTL_ADD: - case EPOLL_CTL_MOD: - ev.events = events; - ev.data.fd = fd; - Py_BEGIN_ALLOW_THREADS - result = epoll_ctl(epfd, op, fd, &ev); - Py_END_ALLOW_THREADS - break; - case EPOLL_CTL_DEL: - /* In kernel versions before 2.6.9, the EPOLL_CTL_DEL - * operation required a non-NULL pointer in event, even - * though this argument is ignored. */ - Py_BEGIN_ALLOW_THREADS - result = epoll_ctl(epfd, op, fd, &ev); - if (errno == EBADF) { - /* fd already closed */ - result = 0; - errno = 0; - } - Py_END_ALLOW_THREADS - break; - default: - result = -1; - errno = EINVAL; - } - - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } - Py_RETURN_NONE; -} - -static PyObject * -pyepoll_register(pyEpoll_Object *self, PyObject *args, PyObject *kwds) -{ - PyObject *pfd; - unsigned int events = EPOLLIN | EPOLLOUT | EPOLLPRI; - static char *kwlist[] = {"fd", "eventmask", NULL}; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|I:register", kwlist, - &pfd, &events)) { - return NULL; - } - - return pyepoll_internal_ctl(self->epfd, EPOLL_CTL_ADD, pfd, events); -} - -PyDoc_STRVAR(pyepoll_register_doc, -"register(fd[, eventmask]) -> None\n\ -\n\ -Registers a new fd or raises an OSError if the fd is already registered.\n\ -fd is the target file descriptor of the operation.\n\ -events is a bit set composed of the various EPOLL constants; the default\n\ -is EPOLL_IN | EPOLL_OUT | EPOLL_PRI.\n\ -\n\ -The epoll interface supports all file descriptors that support poll."); - -static PyObject * -pyepoll_modify(pyEpoll_Object *self, PyObject *args, PyObject *kwds) -{ - PyObject *pfd; - unsigned int events; - static char *kwlist[] = {"fd", "eventmask", NULL}; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "OI:modify", kwlist, - &pfd, &events)) { - return NULL; - } - - return pyepoll_internal_ctl(self->epfd, EPOLL_CTL_MOD, pfd, events); -} - -PyDoc_STRVAR(pyepoll_modify_doc, -"modify(fd, eventmask) -> None\n\ -\n\ -fd is the target file descriptor of the operation\n\ -events is a bit set composed of the various EPOLL constants"); - -static PyObject * -pyepoll_unregister(pyEpoll_Object *self, PyObject *args, PyObject *kwds) -{ - PyObject *pfd; - static char *kwlist[] = {"fd", NULL}; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:unregister", kwlist, - &pfd)) { - return NULL; - } - - return pyepoll_internal_ctl(self->epfd, EPOLL_CTL_DEL, pfd, 0); -} - -PyDoc_STRVAR(pyepoll_unregister_doc, -"unregister(fd) -> None\n\ -\n\ -fd is the target file descriptor of the operation."); - -static PyObject * -pyepoll_poll(pyEpoll_Object *self, PyObject *args, PyObject *kwds) -{ - double dtimeout = -1.; - int timeout; - int maxevents = -1; - int nfds, i; - PyObject *elist = NULL, *etuple = NULL; - struct epoll_event *evs = NULL; - static char *kwlist[] = {"timeout", "maxevents", NULL}; - - if (self->epfd < 0) - return pyepoll_err_closed(); - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|di:poll", kwlist, - &dtimeout, &maxevents)) { - return NULL; - } - - if (dtimeout < 0) { - timeout = -1; - } - else if (dtimeout * 1000.0 > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "timeout is too large"); - return NULL; - } - else { - timeout = (int)(dtimeout * 1000.0); - } - - if (maxevents == -1) { - maxevents = FD_SETSIZE-1; - } - else if (maxevents < 1) { - PyErr_Format(PyExc_ValueError, - "maxevents must be greater than 0, got %d", - maxevents); - return NULL; - } - - evs = PyMem_New(struct epoll_event, maxevents); - if (evs == NULL) { - Py_DECREF(self); - PyErr_NoMemory(); - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - nfds = epoll_wait(self->epfd, evs, maxevents, timeout); - Py_END_ALLOW_THREADS - if (nfds < 0) { - PyErr_SetFromErrno(PyExc_OSError); - goto error; - } - - elist = PyList_New(nfds); - if (elist == NULL) { - goto error; - } - - for (i = 0; i < nfds; i++) { - etuple = Py_BuildValue("iI", evs[i].data.fd, evs[i].events); - if (etuple == NULL) { - Py_CLEAR(elist); - goto error; - } - PyList_SET_ITEM(elist, i, etuple); - } - - error: - PyMem_Free(evs); - return elist; -} - -PyDoc_STRVAR(pyepoll_poll_doc, -"poll([timeout=-1[, maxevents=-1]]) -> [(fd, events), (...)]\n\ -\n\ -Wait for events on the epoll file descriptor for a maximum time of timeout\n\ -in seconds (as float). -1 makes poll wait indefinitely.\n\ -Up to maxevents are returned to the caller."); - -static PyObject * -pyepoll_enter(pyEpoll_Object *self, PyObject *args) -{ - if (self->epfd < 0) - return pyepoll_err_closed(); - - Py_INCREF(self); - return (PyObject *)self; -} - -static PyObject * -pyepoll_exit(PyObject *self, PyObject *args) -{ - _Py_IDENTIFIER(close); - - return _PyObject_CallMethodId(self, &PyId_close, NULL); -} - -static PyMethodDef pyepoll_methods[] = { - {"fromfd", (PyCFunction)pyepoll_fromfd, - METH_VARARGS | METH_CLASS, pyepoll_fromfd_doc}, - {"close", (PyCFunction)pyepoll_close, METH_NOARGS, - pyepoll_close_doc}, - {"fileno", (PyCFunction)pyepoll_fileno, METH_NOARGS, - pyepoll_fileno_doc}, - {"modify", (PyCFunction)pyepoll_modify, - METH_VARARGS | METH_KEYWORDS, pyepoll_modify_doc}, - {"register", (PyCFunction)pyepoll_register, - METH_VARARGS | METH_KEYWORDS, pyepoll_register_doc}, - {"unregister", (PyCFunction)pyepoll_unregister, - METH_VARARGS | METH_KEYWORDS, pyepoll_unregister_doc}, - {"poll", (PyCFunction)pyepoll_poll, - METH_VARARGS | METH_KEYWORDS, pyepoll_poll_doc}, - {"__enter__", (PyCFunction)pyepoll_enter, METH_NOARGS, - NULL}, - {"__exit__", (PyCFunction)pyepoll_exit, METH_VARARGS, - NULL}, - {NULL, NULL}, -}; - -static PyGetSetDef pyepoll_getsetlist[] = { - {"closed", (getter)pyepoll_get_closed, NULL, - "True if the epoll handler is closed"}, - {0}, -}; - -PyDoc_STRVAR(pyepoll_doc, -"select.epoll(sizehint=-1, flags=0)\n\ -\n\ -Returns an epolling object\n\ -\n\ -sizehint must be a positive integer or -1 for the default size. The\n\ -sizehint is used to optimize internal data structures. It doesn't limit\n\ -the maximum number of monitored events."); - -static PyTypeObject pyEpoll_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "select.epoll", /* tp_name */ - sizeof(pyEpoll_Object), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)pyepoll_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - pyepoll_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - pyepoll_methods, /* tp_methods */ - 0, /* tp_members */ - pyepoll_getsetlist, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - pyepoll_new, /* tp_new */ - 0, /* tp_free */ -}; - -#endif /* HAVE_EPOLL */ - -#ifdef HAVE_KQUEUE -/* ************************************************************************** - * kqueue interface for BSD - * - * Copyright (c) 2000 Doug White, 2006 James Knight, 2007 Christian Heimes - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef HAVE_SYS_EVENT_H -#include -#endif - -PyDoc_STRVAR(kqueue_event_doc, -"kevent(ident, filter=KQ_FILTER_READ, flags=KQ_EV_ADD, fflags=0, data=0, udata=0)\n\ -\n\ -This object is the equivalent of the struct kevent for the C API.\n\ -\n\ -See the kqueue manpage for more detailed information about the meaning\n\ -of the arguments.\n\ -\n\ -One minor note: while you might hope that udata could store a\n\ -reference to a python object, it cannot, because it is impossible to\n\ -keep a proper reference count of the object once it's passed into the\n\ -kernel. Therefore, I have restricted it to only storing an integer. I\n\ -recommend ignoring it and simply using the 'ident' field to key off\n\ -of. You could also set up a dictionary on the python side to store a\n\ -udata->object mapping."); - -typedef struct { - PyObject_HEAD - struct kevent e; -} kqueue_event_Object; - -static PyTypeObject kqueue_event_Type; - -#define kqueue_event_Check(op) (PyObject_TypeCheck((op), &kqueue_event_Type)) - -typedef struct { - PyObject_HEAD - SOCKET kqfd; /* kqueue control fd */ -} kqueue_queue_Object; - -static PyTypeObject kqueue_queue_Type; - -#define kqueue_queue_Check(op) (PyObject_TypeCheck((op), &kqueue_queue_Type)) - -#if (SIZEOF_UINTPTR_T != SIZEOF_VOID_P) -# error uintptr_t does not match void *! -#elif (SIZEOF_UINTPTR_T == SIZEOF_LONG_LONG) -# define T_UINTPTRT T_ULONGLONG -# define T_INTPTRT T_LONGLONG -# define PyLong_AsUintptr_t PyLong_AsUnsignedLongLong -# define UINTPTRT_FMT_UNIT "K" -# define INTPTRT_FMT_UNIT "L" -#elif (SIZEOF_UINTPTR_T == SIZEOF_LONG) -# define T_UINTPTRT T_ULONG -# define T_INTPTRT T_LONG -# define PyLong_AsUintptr_t PyLong_AsUnsignedLong -# define UINTPTRT_FMT_UNIT "k" -# define INTPTRT_FMT_UNIT "l" -#elif (SIZEOF_UINTPTR_T == SIZEOF_INT) -# define T_UINTPTRT T_UINT -# define T_INTPTRT T_INT -# define PyLong_AsUintptr_t PyLong_AsUnsignedLong -# define UINTPTRT_FMT_UNIT "I" -# define INTPTRT_FMT_UNIT "i" -#else -# error uintptr_t does not match int, long, or long long! -#endif - -/* - * kevent is not standard and its members vary across BSDs. - */ -#if !defined(__OpenBSD__) -# define IDENT_TYPE T_UINTPTRT -# define IDENT_CAST Py_intptr_t -# define DATA_TYPE T_INTPTRT -# define DATA_FMT_UNIT INTPTRT_FMT_UNIT -# define IDENT_AsType PyLong_AsUintptr_t -#else -# define IDENT_TYPE T_UINT -# define IDENT_CAST int -# define DATA_TYPE T_INT -# define DATA_FMT_UNIT "i" -# define IDENT_AsType PyLong_AsUnsignedLong -#endif - -/* Unfortunately, we can't store python objects in udata, because - * kevents in the kernel can be removed without warning, which would - * forever lose the refcount on the object stored with it. - */ - -#define KQ_OFF(x) offsetof(kqueue_event_Object, x) -static struct PyMemberDef kqueue_event_members[] = { - {"ident", IDENT_TYPE, KQ_OFF(e.ident)}, - {"filter", T_SHORT, KQ_OFF(e.filter)}, - {"flags", T_USHORT, KQ_OFF(e.flags)}, - {"fflags", T_UINT, KQ_OFF(e.fflags)}, - {"data", DATA_TYPE, KQ_OFF(e.data)}, - {"udata", T_UINTPTRT, KQ_OFF(e.udata)}, - {NULL} /* Sentinel */ -}; -#undef KQ_OFF - -static PyObject * - -kqueue_event_repr(kqueue_event_Object *s) -{ - char buf[1024]; - PyOS_snprintf( - buf, sizeof(buf), - "", - (size_t)(s->e.ident), s->e.filter, s->e.flags, - s->e.fflags, (Py_ssize_t)(s->e.data), s->e.udata); - return PyUnicode_FromString(buf); -} - -static int -kqueue_event_init(kqueue_event_Object *self, PyObject *args, PyObject *kwds) -{ - PyObject *pfd; - static char *kwlist[] = {"ident", "filter", "flags", "fflags", - "data", "udata", NULL}; - static char *fmt = "O|hhi" DATA_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent"; - - EV_SET(&(self->e), 0, EVFILT_READ, EV_ADD, 0, 0, 0); /* defaults */ - - if (!PyArg_ParseTupleAndKeywords(args, kwds, fmt, kwlist, - &pfd, &(self->e.filter), &(self->e.flags), - &(self->e.fflags), &(self->e.data), &(self->e.udata))) { - return -1; - } - - if (PyLong_Check(pfd) -#if IDENT_TYPE == T_UINT - && PyLong_AsUnsignedLong(pfd) <= UINT_MAX -#endif - ) { - self->e.ident = IDENT_AsType(pfd); - } - else { - self->e.ident = PyObject_AsFileDescriptor(pfd); - } - if (PyErr_Occurred()) { - return -1; - } - return 0; -} - -static PyObject * -kqueue_event_richcompare(kqueue_event_Object *s, kqueue_event_Object *o, - int op) -{ - Py_intptr_t result = 0; - - if (!kqueue_event_Check(o)) { - if (op == Py_EQ || op == Py_NE) { - PyObject *res = op == Py_EQ ? Py_False : Py_True; - Py_INCREF(res); - return res; - } - PyErr_Format(PyExc_TypeError, - "can't compare %.200s to %.200s", - Py_TYPE(s)->tp_name, Py_TYPE(o)->tp_name); - return NULL; - } - if (((result = (IDENT_CAST)(s->e.ident - o->e.ident)) == 0) && - ((result = s->e.filter - o->e.filter) == 0) && - ((result = s->e.flags - o->e.flags) == 0) && - ((result = (int)(s->e.fflags - o->e.fflags)) == 0) && - ((result = s->e.data - o->e.data) == 0) && - ((result = s->e.udata - o->e.udata) == 0) - ) { - result = 0; - } - - switch (op) { - case Py_EQ: - result = (result == 0); - break; - case Py_NE: - result = (result != 0); - break; - case Py_LE: - result = (result <= 0); - break; - case Py_GE: - result = (result >= 0); - break; - case Py_LT: - result = (result < 0); - break; - case Py_GT: - result = (result > 0); - break; - } - return PyBool_FromLong((long)result); -} - -static PyTypeObject kqueue_event_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "select.kevent", /* tp_name */ - sizeof(kqueue_event_Object), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc)kqueue_event_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - kqueue_event_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - (richcmpfunc)kqueue_event_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - kqueue_event_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)kqueue_event_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ -}; - -static PyObject * -kqueue_queue_err_closed(void) -{ - PyErr_SetString(PyExc_ValueError, "I/O operation on closed kqueue fd"); - return NULL; -} - -static int -kqueue_queue_internal_close(kqueue_queue_Object *self) -{ - int save_errno = 0; - if (self->kqfd >= 0) { - int kqfd = self->kqfd; - self->kqfd = -1; - Py_BEGIN_ALLOW_THREADS - if (close(kqfd) < 0) - save_errno = errno; - Py_END_ALLOW_THREADS - } - return save_errno; -} - -static PyObject * -newKqueue_Object(PyTypeObject *type, SOCKET fd) -{ - kqueue_queue_Object *self; - assert(type != NULL && type->tp_alloc != NULL); - self = (kqueue_queue_Object *) type->tp_alloc(type, 0); - if (self == NULL) { - return NULL; - } - - if (fd == -1) { - Py_BEGIN_ALLOW_THREADS - self->kqfd = kqueue(); - Py_END_ALLOW_THREADS - } - else { - self->kqfd = fd; - } - if (self->kqfd < 0) { - Py_DECREF(self); - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } - return (PyObject *)self; -} - -static PyObject * -kqueue_queue_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - - if ((args != NULL && PyObject_Size(args)) || - (kwds != NULL && PyObject_Size(kwds))) { - PyErr_SetString(PyExc_ValueError, - "select.kqueue doesn't accept arguments"); - return NULL; - } - - return newKqueue_Object(type, -1); -} - -static void -kqueue_queue_dealloc(kqueue_queue_Object *self) -{ - kqueue_queue_internal_close(self); - Py_TYPE(self)->tp_free(self); -} - -static PyObject* -kqueue_queue_close(kqueue_queue_Object *self) -{ - errno = kqueue_queue_internal_close(self); - if (errno < 0) { - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } - Py_RETURN_NONE; -} - -PyDoc_STRVAR(kqueue_queue_close_doc, -"close() -> None\n\ -\n\ -Close the kqueue control file descriptor. Further operations on the kqueue\n\ -object will raise an exception."); - -static PyObject* -kqueue_queue_get_closed(kqueue_queue_Object *self) -{ - if (self->kqfd < 0) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyObject* -kqueue_queue_fileno(kqueue_queue_Object *self) -{ - if (self->kqfd < 0) - return kqueue_queue_err_closed(); - return PyLong_FromLong(self->kqfd); -} - -PyDoc_STRVAR(kqueue_queue_fileno_doc, -"fileno() -> int\n\ -\n\ -Return the kqueue control file descriptor."); - -static PyObject* -kqueue_queue_fromfd(PyObject *cls, PyObject *args) -{ - SOCKET fd; - - if (!PyArg_ParseTuple(args, "i:fromfd", &fd)) - return NULL; - - return newKqueue_Object((PyTypeObject*)cls, fd); -} - -PyDoc_STRVAR(kqueue_queue_fromfd_doc, -"fromfd(fd) -> kqueue\n\ -\n\ -Create a kqueue object from a given control fd."); - -static PyObject * -kqueue_queue_control(kqueue_queue_Object *self, PyObject *args) -{ - int nevents = 0; - int gotevents = 0; - int nchanges = 0; - int i = 0; - PyObject *otimeout = NULL; - PyObject *ch = NULL; - PyObject *it = NULL, *ei = NULL; - PyObject *result = NULL; - struct kevent *evl = NULL; - struct kevent *chl = NULL; - struct timespec timeout; - struct timespec *ptimeoutspec; - - if (self->kqfd < 0) - return kqueue_queue_err_closed(); - - if (!PyArg_ParseTuple(args, "Oi|O:control", &ch, &nevents, &otimeout)) - return NULL; - - if (nevents < 0) { - PyErr_Format(PyExc_ValueError, - "Length of eventlist must be 0 or positive, got %d", - nevents); - return NULL; - } - - if (otimeout == Py_None || otimeout == NULL) { - ptimeoutspec = NULL; - } - else if (PyNumber_Check(otimeout)) { - if (_PyTime_ObjectToTimespec(otimeout, - &timeout.tv_sec, &timeout.tv_nsec) == -1) - return NULL; - - if (timeout.tv_sec < 0) { - PyErr_SetString(PyExc_ValueError, - "timeout must be positive or None"); - return NULL; - } - ptimeoutspec = &timeout; - } - else { - PyErr_Format(PyExc_TypeError, - "timeout argument must be an number " - "or None, got %.200s", - Py_TYPE(otimeout)->tp_name); - return NULL; - } - - if (ch != NULL && ch != Py_None) { - it = PyObject_GetIter(ch); - if (it == NULL) { - PyErr_SetString(PyExc_TypeError, - "changelist is not iterable"); - return NULL; - } - nchanges = PyObject_Size(ch); - if (nchanges < 0) { - goto error; - } - - chl = PyMem_New(struct kevent, nchanges); - if (chl == NULL) { - PyErr_NoMemory(); - goto error; - } - i = 0; - while ((ei = PyIter_Next(it)) != NULL) { - if (!kqueue_event_Check(ei)) { - Py_DECREF(ei); - PyErr_SetString(PyExc_TypeError, - "changelist must be an iterable of " - "select.kevent objects"); - goto error; - } else { - chl[i++] = ((kqueue_event_Object *)ei)->e; - } - Py_DECREF(ei); - } - } - Py_CLEAR(it); - - /* event list */ - if (nevents) { - evl = PyMem_New(struct kevent, nevents); - if (evl == NULL) { - PyErr_NoMemory(); - goto error; - } - } - - Py_BEGIN_ALLOW_THREADS - gotevents = kevent(self->kqfd, chl, nchanges, - evl, nevents, ptimeoutspec); - Py_END_ALLOW_THREADS - - if (gotevents == -1) { - PyErr_SetFromErrno(PyExc_OSError); - goto error; - } - - result = PyList_New(gotevents); - if (result == NULL) { - goto error; - } - - for (i = 0; i < gotevents; i++) { - kqueue_event_Object *ch; - - ch = PyObject_New(kqueue_event_Object, &kqueue_event_Type); - if (ch == NULL) { - goto error; - } - ch->e = evl[i]; - PyList_SET_ITEM(result, i, (PyObject *)ch); - } - PyMem_Free(chl); - PyMem_Free(evl); - return result; - - error: - PyMem_Free(chl); - PyMem_Free(evl); - Py_XDECREF(result); - Py_XDECREF(it); - return NULL; -} - -PyDoc_STRVAR(kqueue_queue_control_doc, -"control(changelist, max_events[, timeout=None]) -> eventlist\n\ -\n\ -Calls the kernel kevent function.\n\ -- changelist must be a list of kevent objects describing the changes\n\ - to be made to the kernel's watch list or None.\n\ -- max_events lets you specify the maximum number of events that the\n\ - kernel will return.\n\ -- timeout is the maximum time to wait in seconds, or else None,\n\ - to wait forever. timeout accepts floats for smaller timeouts, too."); - - -static PyMethodDef kqueue_queue_methods[] = { - {"fromfd", (PyCFunction)kqueue_queue_fromfd, - METH_VARARGS | METH_CLASS, kqueue_queue_fromfd_doc}, - {"close", (PyCFunction)kqueue_queue_close, METH_NOARGS, - kqueue_queue_close_doc}, - {"fileno", (PyCFunction)kqueue_queue_fileno, METH_NOARGS, - kqueue_queue_fileno_doc}, - {"control", (PyCFunction)kqueue_queue_control, - METH_VARARGS , kqueue_queue_control_doc}, - {NULL, NULL}, -}; - -static PyGetSetDef kqueue_queue_getsetlist[] = { - {"closed", (getter)kqueue_queue_get_closed, NULL, - "True if the kqueue handler is closed"}, - {0}, -}; - -PyDoc_STRVAR(kqueue_queue_doc, -"Kqueue syscall wrapper.\n\ -\n\ -For example, to start watching a socket for input:\n\ ->>> kq = kqueue()\n\ ->>> sock = socket()\n\ ->>> sock.connect((host, port))\n\ ->>> kq.control([kevent(sock, KQ_FILTER_WRITE, KQ_EV_ADD)], 0)\n\ -\n\ -To wait one second for it to become writeable:\n\ ->>> kq.control(None, 1, 1000)\n\ -\n\ -To stop listening:\n\ ->>> kq.control([kevent(sock, KQ_FILTER_WRITE, KQ_EV_DELETE)], 0)"); - -static PyTypeObject kqueue_queue_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "select.kqueue", /* tp_name */ - sizeof(kqueue_queue_Object), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)kqueue_queue_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - kqueue_queue_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - kqueue_queue_methods, /* tp_methods */ - 0, /* tp_members */ - kqueue_queue_getsetlist, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - kqueue_queue_new, /* tp_new */ - 0, /* tp_free */ -}; - -#endif /* HAVE_KQUEUE */ - - - - - -/* ************************************************************************ */ - -PyDoc_STRVAR(select_doc, -"select(rlist, wlist, xlist[, timeout]) -> (rlist, wlist, xlist)\n\ -\n\ -Wait until one or more file descriptors are ready for some kind of I/O.\n\ -The first three arguments are sequences of file descriptors to be waited for:\n\ -rlist -- wait until ready for reading\n\ -wlist -- wait until ready for writing\n\ -xlist -- wait for an ``exceptional condition''\n\ -If only one kind of condition is required, pass [] for the other lists.\n\ -A file descriptor is either a socket or file object, or a small integer\n\ -gotten from a fileno() method call on one of those.\n\ -\n\ -The optional 4th argument specifies a timeout in seconds; it may be\n\ -a floating point number to specify fractions of seconds. If it is absent\n\ -or None, the call will never time out.\n\ -\n\ -The return value is a tuple of three lists corresponding to the first three\n\ -arguments; each contains the subset of the corresponding file descriptors\n\ -that are ready.\n\ -\n\ -*** IMPORTANT NOTICE ***\n\ -On Windows and OpenVMS, only sockets are supported; on Unix, all file\n\ -descriptors can be used."); - -static PyMethodDef select_methods[] = { - {"select", select_select, METH_VARARGS, select_doc}, -#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) - {"poll", select_poll, METH_NOARGS, poll_doc}, -#endif /* HAVE_POLL */ -#ifdef HAVE_SYS_DEVPOLL_H - {"devpoll", select_devpoll, METH_NOARGS, devpoll_doc}, -#endif - {0, 0}, /* sentinel */ -}; - -PyDoc_STRVAR(module_doc, -"This module supports asynchronous I/O on multiple file descriptors.\n\ -\n\ -*** IMPORTANT NOTICE ***\n\ -On Windows and OpenVMS, only sockets are supported; on Unix, all file descriptors."); - - -static struct PyModuleDef selectmodule = { - PyModuleDef_HEAD_INIT, - "select", - module_doc, - -1, - select_methods, - NULL, - NULL, - NULL, - NULL -}; - - - - -PyMODINIT_FUNC -PyInit_select(void) -{ - PyObject *m; - m = PyModule_Create(&selectmodule); - if (m == NULL) - return NULL; - - Py_INCREF(PyExc_OSError); - PyModule_AddObject(m, "error", PyExc_OSError); - -#ifdef PIPE_BUF -#ifdef HAVE_BROKEN_PIPE_BUF -#undef PIPE_BUF -#define PIPE_BUF 512 -#endif - PyModule_AddIntMacro(m, PIPE_BUF); -#endif - -#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) -#ifdef __APPLE__ - if (select_have_broken_poll()) { - if (PyObject_DelAttrString(m, "poll") == -1) { - PyErr_Clear(); - } - } else { -#else - { -#endif - if (PyType_Ready(&poll_Type) < 0) - return NULL; - PyModule_AddIntMacro(m, POLLIN); - PyModule_AddIntMacro(m, POLLPRI); - PyModule_AddIntMacro(m, POLLOUT); - PyModule_AddIntMacro(m, POLLERR); - PyModule_AddIntMacro(m, POLLHUP); - PyModule_AddIntMacro(m, POLLNVAL); - -#ifdef POLLRDNORM - PyModule_AddIntMacro(m, POLLRDNORM); -#endif -#ifdef POLLRDBAND - PyModule_AddIntMacro(m, POLLRDBAND); -#endif -#ifdef POLLWRNORM - PyModule_AddIntMacro(m, POLLWRNORM); -#endif -#ifdef POLLWRBAND - PyModule_AddIntMacro(m, POLLWRBAND); -#endif -#ifdef POLLMSG - PyModule_AddIntMacro(m, POLLMSG); -#endif - } -#endif /* HAVE_POLL */ - -#ifdef HAVE_SYS_DEVPOLL_H - if (PyType_Ready(&devpoll_Type) < 0) - return NULL; -#endif - -#ifdef HAVE_EPOLL - Py_TYPE(&pyEpoll_Type) = &PyType_Type; - if (PyType_Ready(&pyEpoll_Type) < 0) - return NULL; - - Py_INCREF(&pyEpoll_Type); - PyModule_AddObject(m, "epoll", (PyObject *) &pyEpoll_Type); - - PyModule_AddIntMacro(m, EPOLLIN); - PyModule_AddIntMacro(m, EPOLLOUT); - PyModule_AddIntMacro(m, EPOLLPRI); - PyModule_AddIntMacro(m, EPOLLERR); - PyModule_AddIntMacro(m, EPOLLHUP); - PyModule_AddIntMacro(m, EPOLLET); -#ifdef EPOLLONESHOT - /* Kernel 2.6.2+ */ - PyModule_AddIntMacro(m, EPOLLONESHOT); -#endif - /* PyModule_AddIntConstant(m, "EPOLL_RDHUP", EPOLLRDHUP); */ - PyModule_AddIntMacro(m, EPOLLRDNORM); - PyModule_AddIntMacro(m, EPOLLRDBAND); - PyModule_AddIntMacro(m, EPOLLWRNORM); - PyModule_AddIntMacro(m, EPOLLWRBAND); - PyModule_AddIntMacro(m, EPOLLMSG); - -#ifdef EPOLL_CLOEXEC - PyModule_AddIntMacro(m, EPOLL_CLOEXEC); -#endif -#endif /* HAVE_EPOLL */ - -#ifdef HAVE_KQUEUE - kqueue_event_Type.tp_new = PyType_GenericNew; - Py_TYPE(&kqueue_event_Type) = &PyType_Type; - if(PyType_Ready(&kqueue_event_Type) < 0) - return NULL; - - Py_INCREF(&kqueue_event_Type); - PyModule_AddObject(m, "kevent", (PyObject *)&kqueue_event_Type); - - Py_TYPE(&kqueue_queue_Type) = &PyType_Type; - if(PyType_Ready(&kqueue_queue_Type) < 0) - return NULL; - Py_INCREF(&kqueue_queue_Type); - PyModule_AddObject(m, "kqueue", (PyObject *)&kqueue_queue_Type); - - /* event filters */ - PyModule_AddIntConstant(m, "KQ_FILTER_READ", EVFILT_READ); - PyModule_AddIntConstant(m, "KQ_FILTER_WRITE", EVFILT_WRITE); - PyModule_AddIntConstant(m, "KQ_FILTER_AIO", EVFILT_AIO); - PyModule_AddIntConstant(m, "KQ_FILTER_VNODE", EVFILT_VNODE); - PyModule_AddIntConstant(m, "KQ_FILTER_PROC", EVFILT_PROC); -#ifdef EVFILT_NETDEV - PyModule_AddIntConstant(m, "KQ_FILTER_NETDEV", EVFILT_NETDEV); -#endif - PyModule_AddIntConstant(m, "KQ_FILTER_SIGNAL", EVFILT_SIGNAL); - PyModule_AddIntConstant(m, "KQ_FILTER_TIMER", EVFILT_TIMER); - - /* event flags */ - PyModule_AddIntConstant(m, "KQ_EV_ADD", EV_ADD); - PyModule_AddIntConstant(m, "KQ_EV_DELETE", EV_DELETE); - PyModule_AddIntConstant(m, "KQ_EV_ENABLE", EV_ENABLE); - PyModule_AddIntConstant(m, "KQ_EV_DISABLE", EV_DISABLE); - PyModule_AddIntConstant(m, "KQ_EV_ONESHOT", EV_ONESHOT); - PyModule_AddIntConstant(m, "KQ_EV_CLEAR", EV_CLEAR); - - PyModule_AddIntConstant(m, "KQ_EV_SYSFLAGS", EV_SYSFLAGS); - PyModule_AddIntConstant(m, "KQ_EV_FLAG1", EV_FLAG1); - - PyModule_AddIntConstant(m, "KQ_EV_EOF", EV_EOF); - PyModule_AddIntConstant(m, "KQ_EV_ERROR", EV_ERROR); - - /* READ WRITE filter flag */ - PyModule_AddIntConstant(m, "KQ_NOTE_LOWAT", NOTE_LOWAT); - - /* VNODE filter flags */ - PyModule_AddIntConstant(m, "KQ_NOTE_DELETE", NOTE_DELETE); - PyModule_AddIntConstant(m, "KQ_NOTE_WRITE", NOTE_WRITE); - PyModule_AddIntConstant(m, "KQ_NOTE_EXTEND", NOTE_EXTEND); - PyModule_AddIntConstant(m, "KQ_NOTE_ATTRIB", NOTE_ATTRIB); - PyModule_AddIntConstant(m, "KQ_NOTE_LINK", NOTE_LINK); - PyModule_AddIntConstant(m, "KQ_NOTE_RENAME", NOTE_RENAME); - PyModule_AddIntConstant(m, "KQ_NOTE_REVOKE", NOTE_REVOKE); - - /* PROC filter flags */ - PyModule_AddIntConstant(m, "KQ_NOTE_EXIT", NOTE_EXIT); - PyModule_AddIntConstant(m, "KQ_NOTE_FORK", NOTE_FORK); - PyModule_AddIntConstant(m, "KQ_NOTE_EXEC", NOTE_EXEC); - PyModule_AddIntConstant(m, "KQ_NOTE_PCTRLMASK", NOTE_PCTRLMASK); - PyModule_AddIntConstant(m, "KQ_NOTE_PDATAMASK", NOTE_PDATAMASK); - - PyModule_AddIntConstant(m, "KQ_NOTE_TRACK", NOTE_TRACK); - PyModule_AddIntConstant(m, "KQ_NOTE_CHILD", NOTE_CHILD); - PyModule_AddIntConstant(m, "KQ_NOTE_TRACKERR", NOTE_TRACKERR); - - /* NETDEV filter flags */ -#ifdef EVFILT_NETDEV - PyModule_AddIntConstant(m, "KQ_NOTE_LINKUP", NOTE_LINKUP); - PyModule_AddIntConstant(m, "KQ_NOTE_LINKDOWN", NOTE_LINKDOWN); - PyModule_AddIntConstant(m, "KQ_NOTE_LINKINV", NOTE_LINKINV); -#endif - -#endif /* HAVE_KQUEUE */ - return m; -} diff -r 1287d4c9cd39 PC/VS9.0/select.vcproj --- a/PC/VS9.0/select.vcproj Fri Aug 02 10:22:07 2013 +0200 +++ b/PC/VS9.0/select.vcproj Fri Aug 02 19:45:03 2013 +0200 @@ -527,7 +527,7 @@ Name="Source Files" > diff -r 1287d4c9cd39 PCbuild/readme.txt --- a/PCbuild/readme.txt Fri Aug 02 10:22:07 2013 +0200 +++ b/PCbuild/readme.txt Fri Aug 02 19:45:03 2013 +0200 @@ -92,8 +92,8 @@ pyexpat Python wrapper for accelerated XML parsing, which incorporates stable code from the Expat project: http://sourceforge.net/projects/expat/ -select - selectmodule.c +_select + _selectmodule.c unicodedata large tables of Unicode data winsound diff -r 1287d4c9cd39 PCbuild/select.vcxproj --- a/PCbuild/select.vcxproj Fri Aug 02 10:22:07 2013 +0200 +++ b/PCbuild/select.vcxproj Fri Aug 02 19:45:03 2013 +0200 @@ -220,7 +220,7 @@ - + @@ -231,4 +231,4 @@ - \ No newline at end of file + diff -r 1287d4c9cd39 PCbuild/select.vcxproj.filters --- a/PCbuild/select.vcxproj.filters Fri Aug 02 10:22:07 2013 +0200 +++ b/PCbuild/select.vcxproj.filters Fri Aug 02 19:45:03 2013 +0200 @@ -6,8 +6,8 @@ - + Source Files - \ No newline at end of file + diff -r 1287d4c9cd39 setup.py --- a/setup.py Fri Aug 02 10:22:07 2013 +0200 +++ b/setup.py Fri Aug 02 19:45:03 2013 +0200 @@ -619,7 +619,7 @@ missing.append('spwd') # select(2); not on ancient System V - exts.append( Extension('select', ['selectmodule.c']) ) + exts.append( Extension('_select', ['_selectmodule.c']) ) # Fred Drake's interface to the Python parser exts.append( Extension('parser', ['parsermodule.c']) ) -------------- next part -------------- diff -r 110a10e0733a examples/wsclient.py --- a/examples/wsclient.py Mon Jul 29 10:36:33 2013 -0700 +++ b/examples/wsclient.py Fri Aug 02 19:32:13 2013 +0200 @@ -4,13 +4,13 @@ import base64 import hashlib import os +import select import signal import sys import tulip import tulip.http from tulip.http import websocket -import tulip.selectors WS_KEY = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11" @@ -89,7 +89,7 @@ url = 'http://{}:{}'.format(args.host, args.port) - loop = tulip.SelectorEventLoop(tulip.selectors.SelectSelector()) + loop = tulip.SelectorEventLoop(select.SelectSelector()) tulip.set_event_loop(loop) loop.add_signal_handler(signal.SIGINT, loop.stop) diff -r 110a10e0733a tests/events_test.py --- a/tests/events_test.py Mon Jul 29 10:36:33 2013 -0700 +++ b/tests/events_test.py Fri Aug 02 19:32:13 2013 +0200 @@ -4,6 +4,7 @@ import io import os import re +import select import signal import socket try: @@ -900,33 +901,32 @@ raise unittest.SkipTest( "IocpEventLoop does not have create_datagram_endpoint()") else: - from tulip import selectors from tulip import unix_events - if hasattr(selectors, 'KqueueSelector'): + if hasattr(select, 'KqueueSelector'): class KqueueEventLoopTests(EventLoopTestsMixin, unittest.TestCase): def create_event_loop(self): return unix_events.SelectorEventLoop( - selectors.KqueueSelector()) + select.KqueueSelector()) - if hasattr(selectors, 'EpollSelector'): + if hasattr(select, 'EpollSelector'): class EPollEventLoopTests(EventLoopTestsMixin, unittest.TestCase): def create_event_loop(self): - return unix_events.SelectorEventLoop(selectors.EpollSelector()) + return unix_events.SelectorEventLoop(select.EpollSelector()) - if hasattr(selectors, 'PollSelector'): + if hasattr(select, 'PollSelector'): class PollEventLoopTests(EventLoopTestsMixin, unittest.TestCase): def create_event_loop(self): - return unix_events.SelectorEventLoop(selectors.PollSelector()) + return unix_events.SelectorEventLoop(select.PollSelector()) # Should always exist. class SelectEventLoopTests(EventLoopTestsMixin, unittest.TestCase): def create_event_loop(self): - return unix_events.SelectorEventLoop(selectors.SelectSelector()) + return unix_events.SelectorEventLoop(select.SelectSelector()) class HandleTests(unittest.TestCase): diff -r 110a10e0733a tests/selector_events_test.py --- a/tests/selector_events_test.py Mon Jul 29 10:36:33 2013 -0700 +++ b/tests/selector_events_test.py Fri Aug 02 19:32:13 2013 +0200 @@ -1,6 +1,7 @@ """Tests for selector_events.py""" import errno +import select import socket import unittest import unittest.mock @@ -10,7 +11,6 @@ ssl = None from tulip import futures -from tulip import selectors from tulip.events import AbstractEventLoop from tulip.protocols import DatagramProtocol, Protocol from tulip.selector_events import BaseSelectorEventLoop @@ -399,7 +399,7 @@ self.assertTrue(self.loop._selector.register.called) fd, mask, (r, w) = self.loop._selector.register.call_args[0] self.assertEqual(1, fd) - self.assertEqual(selectors.EVENT_READ, mask) + self.assertEqual(select.EVENT_READ, mask) self.assertEqual(cb, r._callback) self.assertEqual(None, w) @@ -407,7 +407,7 @@ reader = unittest.mock.Mock() writer = unittest.mock.Mock() self.loop._selector.get_info.return_value = ( - selectors.EVENT_WRITE, (reader, writer)) + select.EVENT_WRITE, (reader, writer)) cb = lambda: True self.loop.add_reader(1, cb) @@ -416,14 +416,14 @@ self.assertTrue(self.loop._selector.modify.called) fd, mask, (r, w) = self.loop._selector.modify.call_args[0] self.assertEqual(1, fd) - self.assertEqual(selectors.EVENT_WRITE | selectors.EVENT_READ, mask) + self.assertEqual(select.EVENT_WRITE | select.EVENT_READ, mask) self.assertEqual(cb, r._callback) self.assertEqual(writer, w) def test_add_reader_existing_writer(self): writer = unittest.mock.Mock() self.loop._selector.get_info.return_value = ( - selectors.EVENT_WRITE, (None, writer)) + select.EVENT_WRITE, (None, writer)) cb = lambda: True self.loop.add_reader(1, cb) @@ -431,13 +431,13 @@ self.assertTrue(self.loop._selector.modify.called) fd, mask, (r, w) = self.loop._selector.modify.call_args[0] self.assertEqual(1, fd) - self.assertEqual(selectors.EVENT_WRITE | selectors.EVENT_READ, mask) + self.assertEqual(select.EVENT_WRITE | select.EVENT_READ, mask) self.assertEqual(cb, r._callback) self.assertEqual(writer, w) def test_remove_reader(self): self.loop._selector.get_info.return_value = ( - selectors.EVENT_READ, (None, None)) + select.EVENT_READ, (None, None)) self.assertFalse(self.loop.remove_reader(1)) self.assertTrue(self.loop._selector.unregister.called) @@ -446,13 +446,13 @@ reader = unittest.mock.Mock() writer = unittest.mock.Mock() self.loop._selector.get_info.return_value = ( - selectors.EVENT_READ | selectors.EVENT_WRITE, (reader, writer)) + select.EVENT_READ | select.EVENT_WRITE, (reader, writer)) self.assertTrue( self.loop.remove_reader(1)) self.assertFalse(self.loop._selector.unregister.called) self.assertEqual( - (1, selectors.EVENT_WRITE, (None, writer)), + (1, select.EVENT_WRITE, (None, writer)), self.loop._selector.modify.call_args[0]) def test_remove_reader_unknown(self): @@ -468,7 +468,7 @@ self.assertTrue(self.loop._selector.register.called) fd, mask, (r, w) = self.loop._selector.register.call_args[0] self.assertEqual(1, fd) - self.assertEqual(selectors.EVENT_WRITE, mask) + self.assertEqual(select.EVENT_WRITE, mask) self.assertEqual(None, r) self.assertEqual(cb, w._callback) @@ -476,7 +476,7 @@ reader = unittest.mock.Mock() writer = unittest.mock.Mock() self.loop._selector.get_info.return_value = ( - selectors.EVENT_READ, (reader, writer)) + select.EVENT_READ, (reader, writer)) cb = lambda: True self.loop.add_writer(1, cb) @@ -485,13 +485,13 @@ self.assertTrue(self.loop._selector.modify.called) fd, mask, (r, w) = self.loop._selector.modify.call_args[0] self.assertEqual(1, fd) - self.assertEqual(selectors.EVENT_WRITE | selectors.EVENT_READ, mask) + self.assertEqual(select.EVENT_WRITE | select.EVENT_READ, mask) self.assertEqual(reader, r) self.assertEqual(cb, w._callback) def test_remove_writer(self): self.loop._selector.get_info.return_value = ( - selectors.EVENT_WRITE, (None, None)) + select.EVENT_WRITE, (None, None)) self.assertFalse(self.loop.remove_writer(1)) self.assertTrue(self.loop._selector.unregister.called) @@ -500,13 +500,13 @@ reader = unittest.mock.Mock() writer = unittest.mock.Mock() self.loop._selector.get_info.return_value = ( - selectors.EVENT_READ | selectors.EVENT_WRITE, (reader, writer)) + select.EVENT_READ | select.EVENT_WRITE, (reader, writer)) self.assertTrue( self.loop.remove_writer(1)) self.assertFalse(self.loop._selector.unregister.called) self.assertEqual( - (1, selectors.EVENT_READ, (reader, None)), + (1, select.EVENT_READ, (reader, None)), self.loop._selector.modify.call_args[0]) def test_remove_writer_unknown(self): @@ -520,7 +520,7 @@ self.loop._add_callback = unittest.mock.Mock() self.loop._process_events( - ((1, selectors.EVENT_READ, (reader, None)),)) + ((1, select.EVENT_READ, (reader, None)),)) self.assertTrue(self.loop._add_callback.called) self.loop._add_callback.assert_called_with(reader) @@ -530,7 +530,7 @@ self.loop.remove_reader = unittest.mock.Mock() self.loop._process_events( - ((1, selectors.EVENT_READ, (reader, None)),)) + ((1, select.EVENT_READ, (reader, None)),)) self.loop.remove_reader.assert_called_with(1) def test_process_events_write(self): @@ -539,7 +539,7 @@ self.loop._add_callback = unittest.mock.Mock() self.loop._process_events( - ((1, selectors.EVENT_WRITE, (None, writer)),)) + ((1, select.EVENT_WRITE, (None, writer)),)) self.loop._add_callback.assert_called_with(writer) def test_process_events_write_cancelled(self): @@ -548,7 +548,7 @@ self.loop.remove_writer = unittest.mock.Mock() self.loop._process_events( - ((1, selectors.EVENT_WRITE, (None, writer)),)) + ((1, select.EVENT_WRITE, (None, writer)),)) self.loop.remove_writer.assert_called_with(1) diff -r 110a10e0733a tests/selectors_test.py --- a/tests/selectors_test.py Mon Jul 29 10:36:33 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,143 +0,0 @@ -"""Tests for selectors.py.""" - -import unittest -import unittest.mock - -from tulip import selectors - - -class BaseSelectorTests(unittest.TestCase): - - def test_fileobj_to_fd(self): - self.assertEqual(10, selectors._fileobj_to_fd(10)) - - f = unittest.mock.Mock() - f.fileno.return_value = 10 - self.assertEqual(10, selectors._fileobj_to_fd(f)) - - f.fileno.side_effect = TypeError - self.assertRaises(ValueError, selectors._fileobj_to_fd, f) - - def test_selector_key_repr(self): - key = selectors.SelectorKey(10, selectors.EVENT_READ) - self.assertEqual( - "SelectorKey", repr(key)) - - def test_register(self): - fobj = unittest.mock.Mock() - fobj.fileno.return_value = 10 - - s = selectors._BaseSelector() - key = s.register(fobj, selectors.EVENT_READ) - self.assertIsInstance(key, selectors.SelectorKey) - self.assertEqual(key.fd, 10) - self.assertIs(key, s._fd_to_key[10]) - - def test_register_unknown_event(self): - s = selectors._BaseSelector() - self.assertRaises(ValueError, s.register, unittest.mock.Mock(), 999999) - - def test_register_already_registered(self): - fobj = unittest.mock.Mock() - fobj.fileno.return_value = 10 - - s = selectors._BaseSelector() - s.register(fobj, selectors.EVENT_READ) - self.assertRaises(ValueError, s.register, fobj, selectors.EVENT_READ) - - def test_unregister(self): - fobj = unittest.mock.Mock() - fobj.fileno.return_value = 10 - - s = selectors._BaseSelector() - s.register(fobj, selectors.EVENT_READ) - s.unregister(fobj) - self.assertFalse(s._fd_to_key) - self.assertFalse(s._fileobj_to_key) - - def test_unregister_unknown(self): - s = selectors._BaseSelector() - self.assertRaises(ValueError, s.unregister, unittest.mock.Mock()) - - def test_modify_unknown(self): - s = selectors._BaseSelector() - self.assertRaises(ValueError, s.modify, unittest.mock.Mock(), 1) - - def test_modify(self): - fobj = unittest.mock.Mock() - fobj.fileno.return_value = 10 - - s = selectors._BaseSelector() - key = s.register(fobj, selectors.EVENT_READ) - key2 = s.modify(fobj, selectors.EVENT_WRITE) - self.assertNotEqual(key.events, key2.events) - self.assertEqual((selectors.EVENT_WRITE, None), s.get_info(fobj)) - - def test_modify_data(self): - fobj = unittest.mock.Mock() - fobj.fileno.return_value = 10 - - d1 = object() - d2 = object() - - s = selectors._BaseSelector() - key = s.register(fobj, selectors.EVENT_READ, d1) - key2 = s.modify(fobj, selectors.EVENT_READ, d2) - self.assertEqual(key.events, key2.events) - self.assertNotEqual(key.data, key2.data) - self.assertEqual((selectors.EVENT_READ, d2), s.get_info(fobj)) - - def test_modify_same(self): - fobj = unittest.mock.Mock() - fobj.fileno.return_value = 10 - - data = object() - - s = selectors._BaseSelector() - key = s.register(fobj, selectors.EVENT_READ, data) - key2 = s.modify(fobj, selectors.EVENT_READ, data) - self.assertIs(key, key2) - - def test_select(self): - s = selectors._BaseSelector() - self.assertRaises(NotImplementedError, s.select) - - def test_close(self): - s = selectors._BaseSelector() - s.register(1, selectors.EVENT_READ) - - s.close() - self.assertFalse(s._fd_to_key) - self.assertFalse(s._fileobj_to_key) - - def test_registered_count(self): - s = selectors._BaseSelector() - self.assertEqual(0, s.registered_count()) - - s.register(1, selectors.EVENT_READ) - self.assertEqual(1, s.registered_count()) - - s.unregister(1) - self.assertEqual(0, s.registered_count()) - - def test_context_manager(self): - s = selectors._BaseSelector() - - with s as sel: - sel.register(1, selectors.EVENT_READ) - - self.assertFalse(s._fd_to_key) - self.assertFalse(s._fileobj_to_key) - - @unittest.mock.patch('tulip.selectors.tulip_log') - def test_key_from_fd(self, m_log): - s = selectors._BaseSelector() - key = s.register(1, selectors.EVENT_READ) - - self.assertIs(key, s._key_from_fd(1)) - self.assertIsNone(s._key_from_fd(10)) - m_log.warning.assert_called_with('No key found for fd %r', 10) - - if hasattr(selectors.DefaultSelector, 'fileno'): - def test_fileno(self): - self.assertIsInstance(selectors.DefaultSelector().fileno(), int) diff -r 110a10e0733a tulip/selector_events.py --- a/tulip/selector_events.py Mon Jul 29 10:36:33 2013 -0700 +++ b/tulip/selector_events.py Fri Aug 02 19:32:13 2013 +0200 @@ -5,6 +5,7 @@ """ import collections +import select import socket try: import ssl @@ -15,7 +16,6 @@ from . import constants from . import events from . import futures -from . import selectors from . import transports from .log import tulip_log @@ -43,7 +43,7 @@ super().__init__() if selector is None: - selector = selectors.DefaultSelector() + selector = select.DefaultSelector() tulip_log.debug('Using selector: %s', selector.__class__.__name__) self._selector = selector self._make_self_pipe() @@ -131,10 +131,10 @@ try: mask, (reader, writer) = self._selector.get_info(fd) except KeyError: - self._selector.register(fd, selectors.EVENT_READ, + self._selector.register(fd, select.EVENT_READ, (handle, None)) else: - self._selector.modify(fd, mask | selectors.EVENT_READ, + self._selector.modify(fd, mask | select.EVENT_READ, (handle, writer)) if reader is not None: reader.cancel() @@ -146,7 +146,7 @@ except KeyError: return False else: - mask &= ~selectors.EVENT_READ + mask &= ~select.EVENT_READ if not mask: self._selector.unregister(fd) else: @@ -164,10 +164,10 @@ try: mask, (reader, writer) = self._selector.get_info(fd) except KeyError: - self._selector.register(fd, selectors.EVENT_WRITE, + self._selector.register(fd, select.EVENT_WRITE, (None, handle)) else: - self._selector.modify(fd, mask | selectors.EVENT_WRITE, + self._selector.modify(fd, mask | select.EVENT_WRITE, (reader, handle)) if writer is not None: writer.cancel() @@ -180,7 +180,7 @@ return False else: # Remove both writer and connector. - mask &= ~selectors.EVENT_WRITE + mask &= ~select.EVENT_WRITE if not mask: self._selector.unregister(fd) else: @@ -309,12 +309,12 @@ def _process_events(self, event_list): for fileobj, mask, (reader, writer) in event_list: - if mask & selectors.EVENT_READ and reader is not None: + if mask & select.EVENT_READ and reader is not None: if reader._cancelled: self.remove_reader(fileobj) else: self._add_callback(reader) - if mask & selectors.EVENT_WRITE and writer is not None: + if mask & select.EVENT_WRITE and writer is not None: if writer._cancelled: self.remove_writer(fileobj) else: From report at bugs.python.org Fri Aug 2 23:27:58 2013 From: report at bugs.python.org (Madison May) Date: Fri, 02 Aug 2013 21:27:58 +0000 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375456931.04.0.558889166858.issue18629@psf.upfronthosting.co.za> Message-ID: <1375478878.14.0.279166874419.issue18629@psf.upfronthosting.co.za> Madison May added the comment: I agree -- it's not at all intuitive that the floor division returns a decimal number of seconds, while float division raises an error. This should probably be cleaned up. In python 3.4, both float division and integer division return decimal numbers of seconds -- that's not all that intuitive, either. Python 3.4.0a0 (default:d5536c06a082+, Jul 11 2013, 20:23:54) [GCC 4.8.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from datetime import timedelta >>> print(timedelta(seconds=3)/2) 0:00:01.500000 >>> print(timedelta(seconds=3)//2) 0:00:01.500000 ---------- nosy: +madison.may _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 23:33:12 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Fri, 02 Aug 2013 21:33:12 +0000 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375456931.04.0.558889166858.issue18629@psf.upfronthosting.co.za> Message-ID: <1375479192.77.0.0833014536025.issue18629@psf.upfronthosting.co.za> Changes by Antoine Pitrou : ---------- nosy: +belopolsky, lemburg _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 23:42:59 2013 From: report at bugs.python.org (Madison May) Date: Fri, 02 Aug 2013 21:42:59 +0000 Subject: [issue8998] add crypto routines to stdlib In-Reply-To: <1276551598.69.0.32913607148.issue8998@psf.upfronthosting.co.za> Message-ID: <1375479779.99.0.778346245122.issue8998@psf.upfronthosting.co.za> Madison May added the comment: This issue may have been dead for 3+ years, but perhaps it's time its brought back to the surface. Aside from simple being convenient for general security practices, a stdlib module for crypto routines would enable python to handle encrypted zipfiles and resolve issues like issue9170. Currently, only hashlib and hmac are available to users (see http://docs.python.org/3/library/crypto.html). I'd imagine that collaboration with the likes of Dwayne from PyCrypto or further collaboration with Geremy from Evpy would be possible, and perhaps the stdlib could build on a 3rd party crypto library. Is anyone else interested in working to make this happen (or does anyone have a good argument against a stdlib crypto library)? I imagine it would be difficult to maintain, but perhaps its at least worth giving this issue a second chance. ---------- nosy: +madison.may _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 23:54:27 2013 From: report at bugs.python.org (Marc-Andre Lemburg) Date: Fri, 02 Aug 2013 21:54:27 +0000 Subject: [issue8998] add crypto routines to stdlib In-Reply-To: <1375479779.99.0.778346245122.issue8998@psf.upfronthosting.co.za> Message-ID: <51FC2A8B.7000305@egenix.com> Marc-Andre Lemburg added the comment: Madison May wrote: > This issue may have been dead for 3+ years, but perhaps it's time its brought back to the surface. Aside from simple being convenient for general security practices, a stdlib module for crypto routines would enable python to handle encrypted zipfiles and resolve issues like issue9170. Currently, only hashlib and hmac are available to users (see http://docs.python.org/3/library/crypto.html). > > I'd imagine that collaboration with the likes of Dwayne from PyCrypto or further collaboration with Geremy from Evpy would be possible, and perhaps the stdlib could build on a 3rd party crypto library. Is anyone else interested in working to make this happen (or does anyone have a good argument against a stdlib crypto library)? I imagine it would be difficult to maintain, but perhaps its at least worth giving this issue a second chance. IMO, it's better to have crypto routines not be part of the stdlib. Not because there's a technical reason. Making crypto code part of the stdlib would create legal issues, e.g. make it illegal to use in some parts of the world. See http://www.cryptolaw.org/ for details. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Aug 2 23:56:50 2013 From: report at bugs.python.org (Madison May) Date: Fri, 02 Aug 2013 21:56:50 +0000 Subject: [issue8998] add crypto routines to stdlib In-Reply-To: <1276551598.69.0.32913607148.issue8998@psf.upfronthosting.co.za> Message-ID: <1375480610.84.0.797617981238.issue8998@psf.upfronthosting.co.za> Madison May added the comment: Yeah, that definitely qualifies as a good argument. I didn't consider the legal issues that would create. Let's let this issue rest in peace, then. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 00:01:19 2013 From: report at bugs.python.org (Gregory P. Smith) Date: Fri, 02 Aug 2013 22:01:19 +0000 Subject: [issue8998] add crypto routines to stdlib In-Reply-To: <1276551598.69.0.32913607148.issue8998@psf.upfronthosting.co.za> Message-ID: <1375480879.36.0.421825405974.issue8998@psf.upfronthosting.co.za> Gregory P. Smith added the comment: The interest is there but nobody is designing or implementing it. Realistically, make a module sporting the proposed API and put it up on pypi and after success there: raise the issue on python-ideas. Read the entire thread here first before designing such a thing. We will always have unsolvable problems in any crypto shipped with Python such as side channel attacks. Those are outside the scope of what the CPython project should ever attempt to solve. Document them as weaknesses and suggest people use C libraries dedicated to avoiding those problems if their security needs require it. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 00:03:09 2013 From: report at bugs.python.org (Gregory P. Smith) Date: Fri, 02 Aug 2013 22:03:09 +0000 Subject: [issue8998] add crypto routines to stdlib In-Reply-To: <1276551598.69.0.32913607148.issue8998@psf.upfronthosting.co.za> Message-ID: <1375480989.61.0.121408019553.issue8998@psf.upfronthosting.co.za> Gregory P. Smith added the comment: Python already ships with SSL support so the legal ship might have sailed ages ago if thats what PSF lawyers say. (IANAL) ---------- resolution: -> later status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 00:09:33 2013 From: report at bugs.python.org (Gregory P. Smith) Date: Fri, 02 Aug 2013 22:09:33 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375258820.22.0.0684222529612.issue18606@psf.upfronthosting.co.za> Message-ID: <1375481373.85.0.998290212438.issue18606@psf.upfronthosting.co.za> Gregory P. Smith added the comment: note, http://docs.scipy.org/doc/scipy/reference/stats.html#statistical-functions is a very popular module for statistics in Python. One of the more frequent things I see people include the entire beast of a code base (scipy and numpy) for is the student's t-test functions. I don't think we can include code from scipy due to license reasons so any implementor should NOT be looking at the scipy code, just the docs for API inspirations. ---------- nosy: +gregory.p.smith _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 00:10:04 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Fri, 02 Aug 2013 22:10:04 +0000 Subject: [issue17934] Add a frame method to clear expensive details In-Reply-To: <1368014042.2.0.41504275061.issue17934@psf.upfronthosting.co.za> Message-ID: <1375481404.08.0.7034157405.issue17934@psf.upfronthosting.co.za> Antoine Pitrou added the comment: Here is an updated patch. Any objections to committing? ---------- Added file: http://bugs.python.org/file31132/frame_clear_alt3.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 00:25:41 2013 From: report at bugs.python.org (Valerie Lambert) Date: Fri, 02 Aug 2013 22:25:41 +0000 Subject: [issue4885] mmap enhancement request In-Reply-To: <1231445893.72.0.162990779773.issue4885@psf.upfronthosting.co.za> Message-ID: <1375482341.21.0.349909002761.issue4885@psf.upfronthosting.co.za> Valerie Lambert added the comment: I just signed and sent the agreement electronically. Let me know if there is anything else I need to do. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 00:43:31 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Fri, 02 Aug 2013 22:43:31 +0000 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375456931.04.0.558889166858.issue18629@psf.upfronthosting.co.za> Message-ID: <1375483411.35.0.146250533736.issue18629@psf.upfronthosting.co.za> Alexander Belopolsky added the comment: I believe this is related to the fact that timedelta * float is not supported in 2.x: Python 2.7.5 (default, May 24 2013, 15:56:16) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from datetime import * >>> timedelta(2) * 0.5 Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for *: 'datetime.timedelta' and 'float' I don't see why this is a barrier to Python 3 transitions. Before you turn on true division you should replace all instances of floor division with '//' anyways. Just treat instances of timedelta / int as you would instances of int / int. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 00:47:52 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Fri, 02 Aug 2013 22:47:52 +0000 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375456931.04.0.558889166858.issue18629@psf.upfronthosting.co.za> Message-ID: <1375483672.39.0.318388706344.issue18629@psf.upfronthosting.co.za> Alexander Belopolsky added the comment: > Does a result of one and one half seconds make sense as the result of a floor division operation? Yes. Timedeltas behave as integers containing the number of microseconds: >>> timedelta(microseconds=1) / 2 datetime.timedelta(0) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 00:47:55 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Fri, 02 Aug 2013 22:47:55 +0000 Subject: [issue16853] add a Selector to the select module In-Reply-To: <1357234686.56.0.503079428281.issue16853@psf.upfronthosting.co.za> Message-ID: <1375483675.16.0.0183350718704.issue16853@psf.upfronthosting.co.za> Charles-Fran?ois Natali added the comment: Version addressing Antoine and Christian's comments. ---------- Added file: http://bugs.python.org/file31133/selector-12.diff _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 01:38:45 2013 From: report at bugs.python.org (Eli Bendersky) Date: Fri, 02 Aug 2013 23:38:45 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375486725.21.0.5394765724.issue18264@psf.upfronthosting.co.za> Eli Bendersky added the comment: I've been reading the discussion again to figure out what we need to move forward; it appears that a simple approach of using str(int(obj)) in json encoding when isinstance(obj, int) was acceptable for many of the participants, and it helps solve the most common problem - the one with IntEnum. We can solve it now, move on to converting socket.* and other constants to IntEnum and perhaps change the solution to something more grandiose later. I'm attaching a proof-of-concept (probably incomplete) patch that implements this for the Python and C implementations of json. With it applied, Nick's example goes like this: >>> from enum import IntEnum >>> import json >>> class Example(IntEnum): x = 1 ... >>> json.dumps(Example.x) '1' >>> json.loads(json.dumps(Example.x)) 1 >>> When thinking about the more generic approaches, we must consider what was raised here already - JSON interoperates with other languages, for which Python's enum is meaningless (think of JavaScript, for instance). So the only logical way to JSON-encode a IntEnum is str(int(...)). ---------- keywords: +patch Added file: http://bugs.python.org/file31134/issue18264.1-prelim.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 01:39:57 2013 From: report at bugs.python.org (Eli Bendersky) Date: Fri, 02 Aug 2013 23:39:57 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375486797.32.0.445467563382.issue18264@psf.upfronthosting.co.za> Eli Bendersky added the comment: [please note that the patch is POC/hacky at best - it's likely to leak memory and be careless and incomplete in other ways. I'm just trying to demonstrate the approach] ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 01:45:54 2013 From: report at bugs.python.org (Eli Bendersky) Date: Fri, 02 Aug 2013 23:45:54 +0000 Subject: [issue18635] Enum sets _member_type_ to instantiated values but not the class In-Reply-To: <1375472056.62.0.564467694147.issue18635@psf.upfronthosting.co.za> Message-ID: <1375487154.02.0.389825613527.issue18635@psf.upfronthosting.co.za> Eli Bendersky added the comment: Can you clarify why it would be useful? Note that we're talking about private non-documented members here. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 01:55:58 2013 From: report at bugs.python.org (Ethan Furman) Date: Fri, 02 Aug 2013 23:55:58 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375487758.54.0.628790032916.issue18264@psf.upfronthosting.co.za> Ethan Furman added the comment: I'll check you patch later against big numbers (which is where I had difficulties). If it works I'll try to make it more complete. If it doesn't, I've been working on just extraction the Enum member's value and using that (works fine on the Python side ;) . Big Question: if the Enum member was used as a key, do we use .name or .value? The decision I went with was to compare the hashes of the member name vs the member itself -- if they're the same, use the .name, otherwise use the value. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 02:05:57 2013 From: report at bugs.python.org (Ethan Furman) Date: Sat, 03 Aug 2013 00:05:57 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375488357.64.0.0405989667564.issue18264@psf.upfronthosting.co.za> Ethan Furman added the comment: I don't think my idea of always extracting .value is grandiose (and didn't take that long to implement on the Python side), but it is definitely forcing me to learn more about C and how Python is put together. It this point I have successfully imported Enum into the _json module; now I'm working on a function to quietly replace the object being encoded with its .value if it is, in fact, an Enum member. Just been real short on time lately. :/ Thank goodness for C API section of the docs! ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 02:13:26 2013 From: report at bugs.python.org (Madison May) Date: Sat, 03 Aug 2013 00:13:26 +0000 Subject: [issue18416] Move to absolute file paths for module.__file__ In-Reply-To: <1373400107.5.0.285657244525.issue18416@psf.upfronthosting.co.za> Message-ID: <1375488806.64.0.934325813706.issue18416@psf.upfronthosting.co.za> Madison May added the comment: PathFinder or FileFinder? Changing PathFinder._path_importer_cache(cls, path) seems to fix the issue. See line 1302 in _bootstrap.py. if path == '': - path = '.' + path = _os.getcwd() $ touch blah.py; ./python -c "import blah; print(blah.__file__)" /home/mmay/cpython/blah.py ---------- nosy: +madison.may _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 02:21:17 2013 From: report at bugs.python.org (Ethan Furman) Date: Sat, 03 Aug 2013 00:21:17 +0000 Subject: [issue18635] Enum sets _member_type_ to instantiated values but not the class In-Reply-To: <1375472056.62.0.564467694147.issue18635@psf.upfronthosting.co.za> Message-ID: <1375489277.81.0.974696504827.issue18635@psf.upfronthosting.co.za> Ethan Furman added the comment: I also admit to being curious as to the reason it is useful, especially since it is, at this point, an implementation detail. Even so, it still makes more sense to have that attribute on the class instead of the instance. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 03:06:14 2013 From: report at bugs.python.org (Roundup Robot) Date: Sat, 03 Aug 2013 01:06:14 +0000 Subject: [issue17046] test_subprocess test_executable_without_cwd fails when run with installed python In-Reply-To: <1359266652.98.0.400492689788.issue17046@psf.upfronthosting.co.za> Message-ID: <3c6Rrj2YGdz7LjN@mail.python.org> Roundup Robot added the comment: New changeset f37b336bfbca by Ned Deily in branch '3.3': Issue #17046: Fix test_subprocess test_executable_without_cwd broken test case. http://hg.python.org/cpython/rev/f37b336bfbca New changeset e3e28ee5b5c3 by Ned Deily in branch 'default': Issue #17046: merge from 3.3 http://hg.python.org/cpython/rev/e3e28ee5b5c3 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 03:15:19 2013 From: report at bugs.python.org (Ned Deily) Date: Sat, 03 Aug 2013 01:15:19 +0000 Subject: [issue17046] test_subprocess test_executable_without_cwd fails when run with installed python In-Reply-To: <1359266652.98.0.400492689788.issue17046@psf.upfronthosting.co.za> Message-ID: <1375492519.24.0.438036362866.issue17046@psf.upfronthosting.co.za> Ned Deily added the comment: test_executable_without_cwd was broken by the test enhancements added for Issue15533. This particular test case is skipped unless the tests are being run from an installed Python rather than from a build directory, the more typical case. The applied patch (for release in 3.3.3 and 3.4.0) fixes the problem. ---------- resolution: -> fixed stage: needs patch -> committed/rejected status: open -> closed versions: -Python 3.2 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 03:56:20 2013 From: report at bugs.python.org (Terry J. Reedy) Date: Sat, 03 Aug 2013 01:56:20 +0000 Subject: [issue11798] Test cases not garbage collected after run In-Reply-To: <1302192957.51.0.450503345302.issue11798@psf.upfronthosting.co.za> Message-ID: <1375494980.19.0.654214173098.issue11798@psf.upfronthosting.co.za> Terry J. Reedy added the comment: If the iterator for 'self' were de-structive, if it removed (popped) the test from whatever structure holds it before yielding it, the messiness of enumerate and the new ._removeTestAtIndex method would not be needed and 'for test in self' would work as desired. If considered necessary, new method .pop_iter, used in 'for test in self.pop_iter', would make it obvious that the iteration empties the collection. ---------- nosy: +terry.reedy _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 04:31:09 2013 From: report at bugs.python.org (Ned Deily) Date: Sat, 03 Aug 2013 02:31:09 +0000 Subject: [issue18270] IDLE on OS X fails with Attribute Error if no initial shell and Tk out-of-date In-Reply-To: <1371739202.98.0.896833417364.issue18270@psf.upfronthosting.co.za> Message-ID: <1375497069.91.0.476240235817.issue18270@psf.upfronthosting.co.za> Ned Deily added the comment: Terry, your patch did not get attached. Do you still have it? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 04:42:35 2013 From: report at bugs.python.org (Ned Deily) Date: Sat, 03 Aug 2013 02:42:35 +0000 Subject: [issue17704] ImportError: No module named '_curses' In-Reply-To: <1365780009.75.0.902696843023.issue17704@psf.upfronthosting.co.za> Message-ID: <1375497755.72.0.407018340231.issue17704@psf.upfronthosting.co.za> Changes by Ned Deily : ---------- status: pending -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 04:52:51 2013 From: report at bugs.python.org (Ned Deily) Date: Sat, 03 Aug 2013 02:52:51 +0000 Subject: [issue17216] sparc linux build fails with "could not import runpy module" In-Reply-To: <1361030549.85.0.142057307455.issue17216@psf.upfronthosting.co.za> Message-ID: <1375498371.69.0.361441367863.issue17216@psf.upfronthosting.co.za> Ned Deily added the comment: Since there has been no further activity on this issue and it seems to be isolated to a particular user build, I'm going to close this. Feel free to reopen with more documentation if you believe there is a problem with Python itself. ---------- resolution: -> invalid stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 05:02:19 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Sat, 03 Aug 2013 03:02:19 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375258820.22.0.0684222529612.issue18606@psf.upfronthosting.co.za> Message-ID: <1375498939.37.0.636197500721.issue18606@psf.upfronthosting.co.za> Alexander Belopolsky added the comment: Is there a reason why there is no "review" link? Could it be because the file is uploaded as is rather than as a patch? In any case, I have a question about this code in sum: # Convert running total to a float. See comment below for # why we do it this way. total = type(total).__float__(total) The "comment below" says: # Don't call float() directly, as that converts strings and we # don't want that. Also, like all dunder methods, we should call # __float__ on the class, not the instance. x = type(x).__float__(x) but this reason does not apply to total that cannot be a string unless you add instances of a really weird class in which case all bets are off and the dunder method won't help much. ---------- nosy: +belopolsky _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 05:19:51 2013 From: report at bugs.python.org (Ned Deily) Date: Sat, 03 Aug 2013 03:19:51 +0000 Subject: [issue15398] intermittence on UnicodeFileTests.test_rename at test_pep277 on MacOS X In-Reply-To: <1342722837.32.0.395738739848.issue15398@psf.upfronthosting.co.za> Message-ID: <1375499991.59.0.489814221957.issue15398@psf.upfronthosting.co.za> Ned Deily added the comment: Has anyone seen this problem on other than OS X 10.6? If not, I suggest we assume it was, in fact, due to a platform bug and close. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 05:22:00 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Sat, 03 Aug 2013 03:22:00 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375258820.22.0.0684222529612.issue18606@psf.upfronthosting.co.za> Message-ID: <1375500120.19.0.896650033196.issue18606@psf.upfronthosting.co.za> Alexander Belopolsky added the comment: The implementation of median and mode families of functions as classes is clever, but I am not sure it is a good idea to return something other than an instance of the class from __new__(). I would prefer to see a more traditional implementation along the lines: class _mode: def __call__(self, data, ..): .. def collate(self, data, ..): .. mode = _mode() ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 05:37:26 2013 From: report at bugs.python.org (=?utf-8?b?SmVzw7pzIENlYSBBdmnDs24=?=) Date: Sat, 03 Aug 2013 03:37:26 +0000 Subject: [issue18599] _sha1module report "SHA" as its name In-Reply-To: <1375189512.2.0.0677739604762.issue18599@psf.upfronthosting.co.za> Message-ID: <1375501046.78.0.20130757769.issue18599@psf.upfronthosting.co.za> Changes by Jes?s Cea Avi?n : ---------- nosy: +jcea _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 05:41:06 2013 From: report at bugs.python.org (=?utf-8?b?SmVzw7pzIENlYSBBdmnDs24=?=) Date: Sat, 03 Aug 2013 03:41:06 +0000 Subject: [issue18595] zipfile: symlinks etc. In-Reply-To: <1375170318.76.0.496081120587.issue18595@psf.upfronthosting.co.za> Message-ID: <1375501266.5.0.157608805297.issue18595@psf.upfronthosting.co.za> Jes?s Cea Avi?n added the comment: Ronald, could you try to write a patch? ---------- nosy: +jcea stage: test needed -> needs patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 05:41:36 2013 From: report at bugs.python.org (=?utf-8?b?SmVzw7pzIENlYSBBdmnDs24=?=) Date: Sat, 03 Aug 2013 03:41:36 +0000 Subject: [issue18594] C accelerator for collections.Counter is slow In-Reply-To: <1375166960.42.0.521563124847.issue18594@psf.upfronthosting.co.za> Message-ID: <1375501296.96.0.61677379268.issue18594@psf.upfronthosting.co.za> Changes by Jes?s Cea Avi?n : ---------- nosy: +jcea _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 05:47:44 2013 From: report at bugs.python.org (=?utf-8?b?SmVzw7pzIENlYSBBdmnDs24=?=) Date: Sat, 03 Aug 2013 03:47:44 +0000 Subject: [issue18602] "_io" module names itself "io" In-Reply-To: <1375214267.87.0.837503153982.issue18602@psf.upfronthosting.co.za> Message-ID: <1375501664.57.0.284486336087.issue18602@psf.upfronthosting.co.za> Changes by Jes?s Cea Avi?n : ---------- nosy: +jcea _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 06:11:24 2013 From: report at bugs.python.org (Terry J. Reedy) Date: Sat, 03 Aug 2013 04:11:24 +0000 Subject: [issue18270] IDLE on OS X fails with Attribute Error if no initial shell and Tk out-of-date In-Reply-To: <1371739202.98.0.896833417364.issue18270@psf.upfronthosting.co.za> Message-ID: <1375503084.79.0.476776348828.issue18270@psf.upfronthosting.co.za> Terry J. Reedy added the comment: No, but I recreated it from my description and attached it. But see next message. ---------- keywords: +patch stage: needs patch -> patch review Added file: http://bugs.python.org/file31135/18270-27.diff _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 06:18:11 2013 From: report at bugs.python.org (=?utf-8?b?SmVzw7pzIENlYSBBdmnDs24=?=) Date: Sat, 03 Aug 2013 04:18:11 +0000 Subject: [issue18574] BaseHTTPRequestHandler.handle_expect_100() sends invalid response In-Reply-To: <1374971787.85.0.837580893432.issue18574@psf.upfronthosting.co.za> Message-ID: <1375503491.75.0.467476360094.issue18574@psf.upfronthosting.co.za> Changes by Jes?s Cea Avi?n : ---------- nosy: +jcea _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 06:21:36 2013 From: report at bugs.python.org (Guido van Rossum) Date: Sat, 03 Aug 2013 04:21:36 +0000 Subject: [issue16853] add a Selector to the select module In-Reply-To: <1357234686.56.0.503079428281.issue16853@psf.upfronthosting.co.za> Message-ID: <1375503696.67.0.390887159285.issue16853@psf.upfronthosting.co.za> Guido van Rossum added the comment: No time for a full review yet, but a comment on the timeout test failure you are observing in Tulip. This particular test schedules a task that sleeps for 20 msecs, and first calls run_until_complete() with a timeout of 10 msecs, and then calls it again without a timeout. It checks that the first call takes approximately 10 msec and the second call too. But for some reason it is okay if the first call takes quite a bit longer (up to 18 msec) and then the second check is wrong. Can you try again with the failing assert replaced with this? self.assertTrue(0.018 <= t2-t0 <= 0.028, t2-t0) That should be a better way to check that code works. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 06:21:56 2013 From: report at bugs.python.org (=?utf-8?b?SmVzw7pzIENlYSBBdmnDs24=?=) Date: Sat, 03 Aug 2013 04:21:56 +0000 Subject: [issue18575] Fixing tarfile._mode when using gzip via ":gz" In-Reply-To: <1375000514.51.0.865237758651.issue18575@psf.upfronthosting.co.za> Message-ID: <1375503716.85.0.576198709702.issue18575@psf.upfronthosting.co.za> Changes by Jes?s Cea Avi?n : ---------- nosy: +jcea _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 06:40:14 2013 From: report at bugs.python.org (Terry J. Reedy) Date: Sat, 03 Aug 2013 04:40:14 +0000 Subject: [issue18270] IDLE on OS X fails with Attribute Error if no initial shell and Tk out-of-date In-Reply-To: <1371739202.98.0.896833417364.issue18270@psf.upfronthosting.co.za> Message-ID: <1375504814.07.0.394085346449.issue18270@psf.upfronthosting.co.za> Terry J. Reedy added the comment: Looking further at handling debug, startup, cmd, or script options. When any of these are set, enable_shell is also, so to reach here, shell must be true, so only the MAC test, the subject of this issue, needs protection. Smaller patch (fewer lines changed) attached. --- Not part of this issue, but if someone can explain ...: This this bit under "if cmd or script:" puzzles me. shell.interp.runcommand("""if 1: import sys as _sys _sys.argv = %r del _sys \n""" % (sys.argv,)) Since the only lasting effect it can have is on the already imported sys module, it seems to be equivalent to sys.argv = "%r" % (sys.argv) And I do not know what net effect that has, if anything. ---------- Added file: http://bugs.python.org/file31136/18270-27-B.diff _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 08:22:29 2013 From: report at bugs.python.org (Julien Nabet) Date: Sat, 03 Aug 2013 06:22:29 +0000 Subject: [issue18521] [cppcheck] Full report In-Reply-To: <1374408848.64.0.369654911435.issue18521@psf.upfronthosting.co.za> Message-ID: <1375510948.99.0.253151104462.issue18521@psf.upfronthosting.co.za> Julien Nabet added the comment: Thank you for your feedback, you can close this tracker. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 09:29:57 2013 From: report at bugs.python.org (Steven D'Aprano) Date: Sat, 03 Aug 2013 07:29:57 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375498939.37.0.636197500721.issue18606@psf.upfronthosting.co.za> Message-ID: <51FCB160.9090303@pearwood.info> Steven D'Aprano added the comment: On 03/08/13 13:02, Alexander Belopolsky wrote: > > Alexander Belopolsky added the comment: > > Is there a reason why there is no "review" link? Could it be because the file is uploaded as is rather than as a patch? I cannot answer that question, sorry. > In any case, I have a question about this code in sum: > > # Convert running total to a float. See comment below for > # why we do it this way. > total = type(total).__float__(total) > > The "comment below" says: > > # Don't call float() directly, as that converts strings and we > # don't want that. Also, like all dunder methods, we should call > # __float__ on the class, not the instance. > x = type(x).__float__(x) > > but this reason does not apply to total that cannot be a string unless you add instances of a really weird class in which case all bets are off and the dunder method won't help much. My reasoning was that total may be a string if the start parameter is a string, but of course I explicitly check the type of start. So I think you are right. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 10:18:14 2013 From: report at bugs.python.org (Ronald Oussoren) Date: Sat, 03 Aug 2013 08:18:14 +0000 Subject: [issue18595] zipfile: symlinks etc. In-Reply-To: <1375170318.76.0.496081120587.issue18595@psf.upfronthosting.co.za> Message-ID: <1375517894.41.0.98354003175.issue18595@psf.upfronthosting.co.za> Ronald Oussoren added the comment: My initial plan was to add the patch soon after filing the issue, but that's before I noticed that this needs some API design to integrate nicely :-) My current idea for the api: * add "symlink(path, target") to write a symlink * add "readlink(path)" to read a symlink * "read" will raise an exception when trying to read a symlink (alternative: do symlink resolving, but that's too magical to my taste) * "extract" and "extractall" extract the symlink as a symlink (but I'm not sure yet what to do on systems that don't support symlinks) * with the various file types it might be better to also provide "islink(name)", "isdir(name)" and "isfile(name)" methods (simular to their os.path equivalents) This will also require some changes to the ZipInfo class. I'm not sure yet if adding support for device files and other unix attributes (UID/GID). ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 10:30:53 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Sat, 03 Aug 2013 08:30:53 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375258820.22.0.0684222529612.issue18606@psf.upfronthosting.co.za> Message-ID: <1375518653.98.0.642731043115.issue18606@psf.upfronthosting.co.za> Vajrasky Kok added the comment: "Is there a reason why there is no 'review' link? Could it be because the file is uploaded as is rather than as a patch?" I think I can answer this question. The answer is yes. You can have "review" only if you use diff not raw file. The original poster, Steven D'Aprano, uploaded the raw file instead of diff. To upload the new file as a diff, (assuming he is using mercurial) he can do something like this: hg add Lib/statistics.py hg diff Lib/statistics.py > /tmp/statistics_diff.patch Then he can upload the statistics_diff.patch. Of course, this is just my hypothetical guess. ---------- nosy: +vajrasky _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 11:21:57 2013 From: report at bugs.python.org (koobs) Date: Sat, 03 Aug 2013 09:21:57 +0000 Subject: [issue16463] testConnectTimeout of test_timeout TCPTimeoutTestCasefailures fails intermittently In-Reply-To: <1352757217.25.0.912881014186.issue16463@psf.upfronthosting.co.za> Message-ID: <1375521717.44.0.543202970733.issue16463@psf.upfronthosting.co.za> Changes by koobs : ---------- nosy: +koobs _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 11:30:40 2013 From: report at bugs.python.org (Phil Connell) Date: Sat, 03 Aug 2013 09:30:40 +0000 Subject: [issue18566] In unittest.TestCase docs for setUp() and tearDown() don't mention AssertionError In-Reply-To: <1374901937.1.0.747872580847.issue18566@psf.upfronthosting.co.za> Message-ID: <1375522240.14.0.0356900597161.issue18566@psf.upfronthosting.co.za> Changes by Phil Connell : ---------- nosy: +pconnell _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 11:34:45 2013 From: report at bugs.python.org (Phil Connell) Date: Sat, 03 Aug 2013 09:34:45 +0000 Subject: [issue18594] C accelerator for collections.Counter is slow In-Reply-To: <1375166960.42.0.521563124847.issue18594@psf.upfronthosting.co.za> Message-ID: <1375522485.37.0.321775223672.issue18594@psf.upfronthosting.co.za> Changes by Phil Connell : ---------- nosy: +pconnell _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 11:41:44 2013 From: report at bugs.python.org (Jean-Paul Calderone) Date: Sat, 03 Aug 2013 09:41:44 +0000 Subject: [issue11798] Test cases not garbage collected after run In-Reply-To: <1302192957.51.0.450503345302.issue11798@psf.upfronthosting.co.za> Message-ID: <1375522904.1.0.911295737544.issue11798@psf.upfronthosting.co.za> Changes by Jean-Paul Calderone : ---------- nosy: -exarkun _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 11:43:09 2013 From: report at bugs.python.org (Jason R. Coombs) Date: Sat, 03 Aug 2013 09:43:09 +0000 Subject: [issue18532] hashlib.HASH objects should officially expose the hash name In-Reply-To: <1374524940.42.0.582552143445.issue18532@psf.upfronthosting.co.za> Message-ID: <1375522988.99.0.101223106292.issue18532@psf.upfronthosting.co.za> Jason R. Coombs added the comment: It's not obvious to me if the authors originally intended to have the 'name' attribute as a formal interface, so I've decided the change should probably be added to Python 3.4. Here's a diff I've put together: http://paste.jaraco.com/tMdQ2 It updates the documentation and adds a test to guarantee the interface. I'm unsure about the RST syntax, so I would appreciate a review of the syntax there. Also, I haven't run the test yet, but I'll do that at a later date. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 11:43:46 2013 From: report at bugs.python.org (Jason R. Coombs) Date: Sat, 03 Aug 2013 09:43:46 +0000 Subject: [issue18532] hashlib.HASH objects should officially expose the hash name In-Reply-To: <1374524940.42.0.582552143445.issue18532@psf.upfronthosting.co.za> Message-ID: <1375523026.38.0.847625289503.issue18532@psf.upfronthosting.co.za> Changes by Jason R. Coombs : ---------- keywords: +needs review stage: needs patch -> patch review _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 12:22:39 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Sat, 03 Aug 2013 10:22:39 +0000 Subject: [issue16853] add a Selector to the select module In-Reply-To: <1375503696.67.0.390887159285.issue16853@psf.upfronthosting.co.za> Message-ID: Charles-Fran?ois Natali added the comment: > Guido van Rossum added the comment: > Can you try again with the failing assert replaced with this? > > self.assertTrue(0.018 <= t2-t0 <= 0.028, t2-t0) > > That should be a better way to check that code works. I'm still getting - less frequent - failures: """ ====================================================================== FAIL: test_run_until_complete_timeout (events_test.SelectEventLoopTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "tests/events_test.py", line 194, in test_run_until_complete_timeout self.assertTrue(0.018 <= t2-t0 <= 0.028, t2-t0) AssertionError: False is not true : 0.029771103999337356 ---------------------------------------------------------------------- """ Looking at strace output: 11:00:47.383145 select(4, [3], [], [], {0, 9765}) = 0 (Timeout) <0.015713> select() takes an extra 5ms (15ms instead of 10ms). 5ms is quite low for a GPOS (the typical quantum is around 4ms for 250Hz timer, and on my machine I have high-resolution timers configured but probably a crappy hardware). I'd suggest increasing the timeouts (especially when Tulip gets merged, it'll likely fail on many buildbots). ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 12:31:43 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Sat, 03 Aug 2013 10:31:43 +0000 Subject: [issue10897] UNIX mmap unnecessarily dup() file descriptor In-Reply-To: <1294845379.76.0.427887707002.issue10897@psf.upfronthosting.co.za> Message-ID: <1375525903.82.0.707473239921.issue10897@psf.upfronthosting.co.za> Charles-Fran?ois Natali added the comment: > This can only be raised (above the hard limit) by a privileged > process, so I would be out of luck there, as I could not convince > my sysadmins to raise this further. We all know that feeling :-) > Meanwhile, I will just use my own module, so feel free to close > this if you feel like it :) OK, I'll close it then, since I don't see any satisfactory solution, and - until now - you've been the only user to get bitten. Cheers. ---------- resolution: -> wont fix stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 12:44:31 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Sat, 03 Aug 2013 10:44:31 +0000 Subject: [issue16463] testConnectTimeout of test_timeout TCPTimeoutTestCasefailures fails intermittently In-Reply-To: <1352757217.25.0.912881014186.issue16463@psf.upfronthosting.co.za> Message-ID: <1375526671.33.0.700169554023.issue16463@psf.upfronthosting.co.za> Charles-Fran?ois Natali added the comment: The problem is that the test passes a DNS address to connect(), which means that it has to perform a name resolution first. And since there's not timeout on gethostbyname()/getaddrinfo() you can end up well above the timeout. The hostnames should be resolved beforehand. ---------- nosy: +neologix _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 12:48:08 2013 From: report at bugs.python.org (Marc-Andre Lemburg) Date: Sat, 03 Aug 2013 10:48:08 +0000 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375483672.39.0.318388706344.issue18629@psf.upfronthosting.co.za> Message-ID: <51FCDFE1.3000108@egenix.com> Marc-Andre Lemburg added the comment: On 03.08.2013 00:47, Alexander Belopolsky wrote: > > Alexander Belopolsky added the comment: > >> Does a result of one and one half seconds make sense as the result of a floor division operation? > > Yes. Timedeltas behave as integers containing the number of microseconds: > >>>> timedelta(microseconds=1) / 2 > datetime.timedelta(0) I think that's a very obscure interpretation of floor division for timedeltas :-) IMO, floor division result should work on seconds, not microseconds. ---------- _______________________________________ Python tracker _______________________________________ From mal at egenix.com Sat Aug 3 12:48:01 2013 From: mal at egenix.com (M.-A. Lemburg) Date: Sat, 03 Aug 2013 12:48:01 +0200 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375483672.39.0.318388706344.issue18629@psf.upfronthosting.co.za> References: <1375483672.39.0.318388706344.issue18629@psf.upfronthosting.co.za> Message-ID: <51FCDFE1.3000108@egenix.com> On 03.08.2013 00:47, Alexander Belopolsky wrote: > > Alexander Belopolsky added the comment: > >> Does a result of one and one half seconds make sense as the result of a floor division operation? > > Yes. Timedeltas behave as integers containing the number of microseconds: > >>>> timedelta(microseconds=1) / 2 > datetime.timedelta(0) I think that's a very obscure interpretation of floor division for timedeltas :-) IMO, floor division result should work on seconds, not microseconds. -- Marc-Andre Lemburg eGenix.com From report at bugs.python.org Sat Aug 3 13:03:16 2013 From: report at bugs.python.org (Mark Dickinson) Date: Sat, 03 Aug 2013 11:03:16 +0000 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375456931.04.0.558889166858.issue18629@psf.upfronthosting.co.za> Message-ID: <1375527796.29.0.652589645391.issue18629@psf.upfronthosting.co.za> Mark Dickinson added the comment: > I think that's a very obscure interpretation of floor division for > timedeltas :-) Agreed. ---------- nosy: +mark.dickinson _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 13:09:29 2013 From: report at bugs.python.org (Mark Dickinson) Date: Sat, 03 Aug 2013 11:09:29 +0000 Subject: [issue18570] OverflowError in division: wrong message In-Reply-To: <1374924685.41.0.945479313268.issue18570@psf.upfronthosting.co.za> Message-ID: <1375528169.52.0.915993153799.issue18570@psf.upfronthosting.co.za> Mark Dickinson added the comment: Exception message fixed in revision dab7d6f33b87 ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 13:25:35 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Sat, 03 Aug 2013 11:25:35 +0000 Subject: [issue16463] testConnectTimeout of test_timeout TCPTimeoutTestCasefailures fails intermittently In-Reply-To: <1375526671.33.0.700169554023.issue16463@psf.upfronthosting.co.za> Message-ID: Charles-Fran?ois Natali added the comment: And here's a patch. ---------- keywords: +patch Added file: http://bugs.python.org/file31137/connect_timeout.diff _______________________________________ Python tracker _______________________________________ -------------- next part -------------- diff -r 1287d4c9cd39 Lib/test/test_timeout.py --- a/Lib/test/test_timeout.py Fri Aug 02 10:22:07 2013 +0200 +++ b/Lib/test/test_timeout.py Sat Aug 03 13:19:24 2013 +0200 @@ -126,13 +126,23 @@ self.assertLess(delta, timeout + self.fuzz) self.assertGreater(delta, timeout - 1.0) + def resolve_address(self, host, port): + """Resolve an (host, port) to an address. + + We must perform name resolution before timeout tests, otherwise it will + be performed by connect(). + """ + with support.transient_internet(host): + return socket.getaddrinfo(host, port, socket.AF_INET, + socket.SOCK_STREAM)[0][4] + class TCPTimeoutTestCase(TimeoutTestCase): """TCP test case for socket.socket() timeout functions""" def setUp(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.addr_remote = ('www.python.org.', 80) + self.addr_remote = self.resolve_address('www.python.org.', 80) def tearDown(self): self.sock.close() @@ -142,7 +152,7 @@ # to a host that silently drops our packets. We can't simulate this # from Python because it's a function of the underlying TCP/IP stack. # So, the following Snakebite host has been defined: - blackhole = ('blackhole.snakebite.net', 56666) + blackhole = self.resolve_address('blackhole.snakebite.net', 56666) # Blackhole has been configured to silently drop any incoming packets. # No RSTs (for TCP) or ICMP UNREACH (for UDP/ICMP) will be sent back @@ -154,7 +164,7 @@ # to firewalling or general network configuration. In order to improve # our confidence in testing the blackhole, a corresponding 'whitehole' # has also been set up using one port higher: - whitehole = ('whitehole.snakebite.net', 56667) + whitehole = self.resolve_address('whitehole.snakebite.net', 56667) # This address has been configured to immediately drop any incoming # packets as well, but it does it respectfully with regards to the From report at bugs.python.org Sat Aug 3 13:53:07 2013 From: report at bugs.python.org (Al Korgun) Date: Sat, 03 Aug 2013 11:53:07 +0000 Subject: [issue18642] enhancement for operator 'assert' Message-ID: <1375530787.73.0.318484624842.issue18642@psf.upfronthosting.co.za> New submission from Al Korgun: It would be pretty good, if 'assert' could raise specified exception, like that: >>> data = None >>> assert isinstance(data, basestring), TypeError("'data' must be a string") AssertionErrorTypeError: 'data' must be a string ---------- components: Interpreter Core messages: 194250 nosy: WitcherGeralt priority: normal severity: normal status: open title: enhancement for operator 'assert' type: enhancement versions: Python 2.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 14:07:10 2013 From: report at bugs.python.org (Mark Dickinson) Date: Sat, 03 Aug 2013 12:07:10 +0000 Subject: [issue18642] enhancement for operator 'assert' In-Reply-To: <1375530787.73.0.318484624842.issue18642@psf.upfronthosting.co.za> Message-ID: <1375531630.05.0.324846148411.issue18642@psf.upfronthosting.co.za> Mark Dickinson added the comment: What's wrong with: if not isinstance(data, basestring): raise TypeError(...) ? In any case, you appear to be wanting to use assert to check user input. That's not its intended use; instead, it's there for making debugging assertions. Bear in mind that when running in optimized mode (with python -O), Python won't execute those asserts at all. (See http://docs.python.org/3.4/reference/simple_stmts.html#the-assert-statement for more.) I think this should be rejected. ---------- nosy: +mark.dickinson versions: +Python 3.4 -Python 2.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 14:11:35 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Sat, 03 Aug 2013 12:11:35 +0000 Subject: [issue18643] implement socketpair() on Windows Message-ID: <1375531895.31.0.501848123953.issue18643@psf.upfronthosting.co.za> New submission from Charles-Fran?ois Natali: socketpair() is quite useful, notably for tests. Currently, it's not defined on Windows. Since it's rather easy to implement, it would be nice to have it, if not in the stdlib, at least in test.support. ---------- components: Library (Lib) messages: 194252 nosy: neologix, sbt priority: normal severity: normal stage: needs patch status: open title: implement socketpair() on Windows type: enhancement _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 14:45:44 2013 From: report at bugs.python.org (Nick Coghlan) Date: Sat, 03 Aug 2013 12:45:44 +0000 Subject: [issue18396] test_signal.test_issue9324() fails on buildbot AMD64 Windows7 SP1 3.x In-Reply-To: <1373208170.43.0.508048091983.issue18396@psf.upfronthosting.co.za> Message-ID: <1375533944.84.0.73911843883.issue18396@psf.upfronthosting.co.za> Nick Coghlan added the comment: I checked the getsignal docs, and indeed None is the expected return value for "signal handler exists, but was not installed from Python". That's accurate given the way faulthandler works: On Linux (Python 3.3.0): $ python3 -c "import signal; print(signal.getsignal(signal.SIGSEGV))" 0 $ python3 -X faulthandler -c "import signal; print(signal.getsignal(signal.SIGSEGV))" None So Jeremy's patch looks correct to me - when faulthandler is enabled, we need to skip over the signals that have those handlers attached. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 14:57:32 2013 From: report at bugs.python.org (Chris Lambacher) Date: Sat, 03 Aug 2013 12:57:32 +0000 Subject: [issue18635] Enum sets _member_type_ to instantiated values but not the class In-Reply-To: <1375472056.62.0.564467694147.issue18635@psf.upfronthosting.co.za> Message-ID: <1375534652.92.0.146277796903.issue18635@psf.upfronthosting.co.za> Chris Lambacher added the comment: My use case is a generic mixin for Enums and a generic mixin for Django ORM fields that uses the Enums to generate choices. The Enum mixin has to call cls.__class__._get_mixins_(cls.__bases__) to get the member_type so that it can call the member_type.__new__ method (currently using this for int and str). I'm currently setting _member_type_ on the class if it doesn't already exist in the Enum class. The Django ORM field mixin has a to_python method where it is supposed to take input from the db/web and turn it into the python type (in this case an Enum). If we get a str from the web and we are going to an int, we need to run int on it. The generic way to do this in the mixin is to pass the value to _member_type_ as a function. I think I have all the bugs out of my implementation so I should be able to extract it out of my app and make it open source this week. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 15:03:41 2013 From: report at bugs.python.org (Roundup Robot) Date: Sat, 03 Aug 2013 13:03:41 +0000 Subject: [issue18396] test_signal.test_issue9324() fails on buildbot AMD64 Windows7 SP1 3.x In-Reply-To: <1373208170.43.0.508048091983.issue18396@psf.upfronthosting.co.za> Message-ID: <3c6lmX3VC2z7LjS@mail.python.org> Roundup Robot added the comment: New changeset b7834800562f by Nick Coghlan in branch '3.3': Close #18396: fix spurious test_signal failure on Windows http://hg.python.org/cpython/rev/b7834800562f New changeset 6fc71ed6a910 by Nick Coghlan in branch 'default': Merge #18396 from 3.3 http://hg.python.org/cpython/rev/6fc71ed6a910 ---------- nosy: +python-dev resolution: -> fixed stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 15:05:18 2013 From: report at bugs.python.org (Nick Coghlan) Date: Sat, 03 Aug 2013 13:05:18 +0000 Subject: [issue18396] test_signal.test_issue9324() fails on buildbot AMD64 Windows7 SP1 3.x In-Reply-To: <1373208170.43.0.508048091983.issue18396@psf.upfronthosting.co.za> Message-ID: <1375535118.68.0.951787951687.issue18396@psf.upfronthosting.co.za> Nick Coghlan added the comment: I added one slight tweak to Jeremy's patch - an assertion to ensure that test loop is checking at least some* signals, even when faulthandler is enabled. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 15:18:09 2013 From: report at bugs.python.org (Al Korgun) Date: Sat, 03 Aug 2013 13:18:09 +0000 Subject: [issue18642] enhancement for operator 'assert' In-Reply-To: <1375530787.73.0.318484624842.issue18642@psf.upfronthosting.co.za> Message-ID: <1375535889.51.0.540228108536.issue18642@psf.upfronthosting.co.za> Al Korgun added the comment: Mark Dickinson, and I just think it might be useful in debug. PYO is another story. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 15:31:31 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Sat, 03 Aug 2013 13:31:31 +0000 Subject: [issue15233] atexit: guarantee order of execution of registered functions? In-Reply-To: <1341129521.95.0.805489135584.issue15233@psf.upfronthosting.co.za> Message-ID: <1375536691.51.0.555057210352.issue15233@psf.upfronthosting.co.za> Charles-Fran?ois Natali added the comment: Unless anyone objects, I'll backport it soonish. ---------- stage: -> commit review _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 15:38:08 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Sat, 03 Aug 2013 13:38:08 +0000 Subject: [issue12015] possible characters in temporary file name is too few In-Reply-To: <1304661107.62.0.977226402655.issue12015@psf.upfronthosting.co.za> Message-ID: <1375537088.29.0.787187267469.issue12015@psf.upfronthosting.co.za> Changes by Charles-Fran?ois Natali : ---------- keywords: +easy, needs review stage: -> patch review type: -> enhancement versions: +Python 3.4 -Python 3.3 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 15:40:07 2013 From: report at bugs.python.org (Mark Dickinson) Date: Sat, 03 Aug 2013 13:40:07 +0000 Subject: [issue18642] enhancement for operator 'assert' In-Reply-To: <1375530787.73.0.318484624842.issue18642@psf.upfronthosting.co.za> Message-ID: <1375537207.25.0.0436984099259.issue18642@psf.upfronthosting.co.za> Mark Dickinson added the comment: Ah, so I think I don't understand the proposal. In your original message, is it your intention that the assert raises TypeError, or that it raises AssertionError? Again: what's the benefit over existing solutions? Either: if not isinstance(data, basestring): raise TypeError("Bad user! You gave me the wrong type") or assert isinstance(data, basestring), "data should be a string at this point" ? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 15:45:19 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Sat, 03 Aug 2013 13:45:19 +0000 Subject: [issue18644] Got ResourceWarning: unclosed file when using test function from formatter module Message-ID: <1375537519.43.0.405840418589.issue18644@psf.upfronthosting.co.za> New submission from Vajrasky Kok: This python is compiled with --with-pydebug option. [sky at localhost cpython]$ cat /tmp/a.txt manly man likes cute cat. [sky at localhost cpython]$ ./python Python 3.4.0a0 (default:e408e821d6c8, Jul 27 2013, 10:49:54) [GCC 4.7.2 20121109 (Red Hat 4.7.2-8)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from formatter import test >>> test('/tmp/a.txt') manly man likes cute cat. __main__:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/a.txt' mode='r' encoding='UTF-8'> >>> [sky at localhost cpython]$ ./python Lib/formatter.py /tmp/a.txt manly man likes cute cat. Lib/formatter.py:445: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/a.txt' mode='r' encoding='UTF-8'> test() ---------- components: Tests files: formatter_fix_resource_warning.patch keywords: patch messages: 194260 nosy: vajrasky priority: normal severity: normal status: open title: Got ResourceWarning: unclosed file when using test function from formatter module type: resource usage versions: Python 3.4 Added file: http://bugs.python.org/file31138/formatter_fix_resource_warning.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 15:51:15 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Sat, 03 Aug 2013 13:51:15 +0000 Subject: [issue18644] Got ResourceWarning: unclosed file when using test function from formatter module In-Reply-To: <1375537519.43.0.405840418589.issue18644@psf.upfronthosting.co.za> Message-ID: <1375537875.72.0.0276940387566.issue18644@psf.upfronthosting.co.za> Vajrasky Kok added the comment: Sorry, I forgot about stdin. Attached the patch to handle stdin gracefully. ---------- Added file: http://bugs.python.org/file31139/formatter_fix_resource_warning_v2.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 16:04:02 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Sat, 03 Aug 2013 14:04:02 +0000 Subject: [issue18644] Got ResourceWarning: unclosed file when using test function from formatter module In-Reply-To: <1375537519.43.0.405840418589.issue18644@psf.upfronthosting.co.za> Message-ID: <1375538642.37.0.997857054625.issue18644@psf.upfronthosting.co.za> Vajrasky Kok added the comment: I guess I should not close stdin just in case people are using test function in the script. Attached the patch to only close the open files not stdin. ---------- Added file: http://bugs.python.org/file31140/formatter_fix_resource_warning_v3.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 16:15:41 2013 From: report at bugs.python.org (R. David Murray) Date: Sat, 03 Aug 2013 14:15:41 +0000 Subject: [issue18642] enhancement for operator 'assert' In-Reply-To: <1375530787.73.0.318484624842.issue18642@psf.upfronthosting.co.za> Message-ID: <1375539341.68.0.629037081423.issue18642@psf.upfronthosting.co.za> R. David Murray added the comment: I think it would be confusing for assert to raise anything other than an AssertionError, so I also think this should be rejected. It might be interesting for there to be a way to call unittest's assert methods in a debug context (that is, without having to have a test case around), but that is a very non-trivial (and probably impractical) thought :) ---------- nosy: +r.david.murray _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 16:30:58 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sat, 03 Aug 2013 14:30:58 +0000 Subject: [issue18595] zipfile: symlinks etc. In-Reply-To: <1375170318.76.0.496081120587.issue18595@psf.upfronthosting.co.za> Message-ID: <1375540258.46.0.150687603014.issue18595@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: > * "read" will raise an exception when trying to read a symlink > (alternative: do symlink resolving, but that's too magical to my taste) And perhaps when trying to read a directory entry too. > * "extract" and "extractall" extract the symlink as a symlink > (but I'm not sure yet what to do on systems that don't support symlinks) What the tar module do? > * with the various file types it might be better to also provide > "islink(name)", "isdir(name)" and "isfile(name)" methods (simular to > their os.path equivalents) Or rather as methods of the ZipInfo object. See TarInfo. ---------- nosy: +serhiy.storchaka _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 16:44:26 2013 From: report at bugs.python.org (Martijn Pieters) Date: Sat, 03 Aug 2013 14:44:26 +0000 Subject: [issue18644] Got ResourceWarning: unclosed file when using test function from formatter module In-Reply-To: <1375537519.43.0.405840418589.issue18644@psf.upfronthosting.co.za> Message-ID: <1375541066.29.0.757166721614.issue18644@psf.upfronthosting.co.za> Martijn Pieters added the comment: Why is the `formatter` module still part of Python 3? This was a dependency for the `htmllib` module in Python 2 only, and that module was deprecated and removed from Python 3. ---------- nosy: +mjpieters _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 16:46:39 2013 From: report at bugs.python.org (Ethan Furman) Date: Sat, 03 Aug 2013 14:46:39 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375541199.66.0.46278775258.issue18264@psf.upfronthosting.co.za> Ethan Furman added the comment: Eli, your method is good. I thought I had tried something similar but I obviously had the wrong PyLong constructor. I'll get it implemented. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 17:33:59 2013 From: report at bugs.python.org (Marc-Andre Lemburg) Date: Sat, 03 Aug 2013 15:33:59 +0000 Subject: [issue18624] Add alias for iso-8859-8-i which is the same as iso-8859-8 In-Reply-To: <1375454262.69.0.534466060897.issue18624@psf.upfronthosting.co.za> Message-ID: <51FD22DE.6030807@egenix.com> Marc-Andre Lemburg added the comment: On 02.08.2013 16:37, R. David Murray wrote: > > I got the impression from what I read that -e included additional control sequences, but perhaps I misunderstood and that only meant that the data stream was expected to *use* additional control sequences but the control codes themselves are part of the base codec? > > I'm specifically thinking of this statement from the linked reference: > > "Because HTML uses the Unicode bidirectionality algorithm, conforming documents encoded using ISO 8859-8 must be labeled as "ISO-8859-8-i". Explicit directional control is also possible with HTML, but cannot be expressed with ISO 8859-8, so "ISO-8859-8-e" should not be used." > > The "cannot be expressed" seems to imply there are differences in the codec. No, not really. After some more research, I found that the -i and -e suffixes are defined in RFC 1556: http://tools.ietf.org/html/rfc1556 At the codec level, these encodings are all the same. The suffixes define whether or not to interpret some of their control characters with respect to bidi text when visualizing the text. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 18:17:33 2013 From: report at bugs.python.org (R. David Murray) Date: Sat, 03 Aug 2013 16:17:33 +0000 Subject: [issue11798] Test cases not garbage collected after run In-Reply-To: <1302192957.51.0.450503345302.issue11798@psf.upfronthosting.co.za> Message-ID: <1375546653.21.0.0671070956824.issue11798@psf.upfronthosting.co.za> R. David Murray added the comment: Terry: I would not be in favor of using the normal iter, since iterating a collection doesn't normally empty it, and there may be tools that iterate a test suite outside of test execution. Adding a pop_iter method would be a backward compatibility issue, since "replacement" test suites would not have that method. I think the current patch is the best bet for maintaining backward compatibility. ---------- nosy: +r.david.murray _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 18:19:56 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Sat, 03 Aug 2013 16:19:56 +0000 Subject: [issue18296] test_os.test_trailers() is failing on AMD64 FreeBSD 9.0 dtrace 3.x In-Reply-To: <1372119942.09.0.162654139201.issue18296@psf.upfronthosting.co.za> Message-ID: <1375546796.57.0.00769754560912.issue18296@psf.upfronthosting.co.za> Charles-Fran?ois Natali added the comment: The test shouldn't pass 4096 as nbytes: apparently, recent FreeBSD kernels zero-fill. ---------- nosy: +neologix _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 18:31:37 2013 From: report at bugs.python.org (Roundup Robot) Date: Sat, 03 Aug 2013 16:31:37 +0000 Subject: [issue17998] internal error in regular expression engine In-Reply-To: <1368803354.84.0.768428094886.issue17998@psf.upfronthosting.co.za> Message-ID: <3c6rNS1rN8zND8@mail.python.org> Roundup Robot added the comment: New changeset 86b8b035529b by Serhiy Storchaka in branch '3.3': Issue #17998: Fix an internal error in regular expression engine. http://hg.python.org/cpython/rev/86b8b035529b New changeset 36702442ffe0 by Serhiy Storchaka in branch 'default': Issue #17998: Fix an internal error in regular expression engine. http://hg.python.org/cpython/rev/36702442ffe0 New changeset e5e425fd1e4f by Serhiy Storchaka in branch '2.7': Issue #17998: Fix an internal error in regular expression engine. http://hg.python.org/cpython/rev/e5e425fd1e4f ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 18:32:10 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Sat, 03 Aug 2013 16:32:10 +0000 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375456931.04.0.558889166858.issue18629@psf.upfronthosting.co.za> Message-ID: <1375547530.36.0.773109260979.issue18629@psf.upfronthosting.co.za> Alexander Belopolsky added the comment: What is so special about seconds? Why not days? As in >>> timedelta(3) // 2 timedelta(1) Note that in 3.x we have timedelta over timedelta division that lets you do floor division in arbitrary time units. What is the use case for timedelta // int that rounds down to a second? I suspect in most cases you really want timedelta // timedelta(seconds=int) instead. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 18:36:18 2013 From: report at bugs.python.org (Mark Dickinson) Date: Sat, 03 Aug 2013 16:36:18 +0000 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375456931.04.0.558889166858.issue18629@psf.upfronthosting.co.za> Message-ID: <1375547778.47.0.626883478405.issue18629@psf.upfronthosting.co.za> Mark Dickinson added the comment: I'm not sure I see a use-case for timedelta // int at all. To make sense of that, you first need some way to make sense of floor(timedelta), and as you say it's not clear what that should mean: number of seconds? number of days? Either of those would seem more natural than number of microseconds, though. timedelta // timedelta and timedelta / int on the other hand have an obvious meaning. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 18:39:45 2013 From: report at bugs.python.org (Mark Dickinson) Date: Sat, 03 Aug 2013 16:39:45 +0000 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375456931.04.0.558889166858.issue18629@psf.upfronthosting.co.za> Message-ID: <1375547985.45.0.720415387332.issue18629@psf.upfronthosting.co.za> Mark Dickinson added the comment: -1 on changing the behaviour in 2.7, though; I think it's far too late for that. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 18:43:50 2013 From: report at bugs.python.org (Marc-Andre Lemburg) Date: Sat, 03 Aug 2013 16:43:50 +0000 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375547530.36.0.773109260979.issue18629@psf.upfronthosting.co.za> Message-ID: <51FD333E.7010400@egenix.com> Marc-Andre Lemburg added the comment: On 03.08.2013 18:32, Alexander Belopolsky wrote: > > Alexander Belopolsky added the comment: > > What is so special about seconds? Why not days? As in > >>>> timedelta(3) // 2 > timedelta(1) > > > Note that in 3.x we have timedelta over timedelta division that lets you do floor division in arbitrary time units. > > What is the use case for timedelta // int that rounds down to a second? I suspect in most cases you really want timedelta // timedelta(seconds=int) instead. The notion of fraction in time usually applies to seconds, not days, hours or minutes. Since floor removes fractions, the natural expectation is to have // int apply to seconds, not microseconds (which represent fractions of a second). That said, I don't think having // division on timedeltas is useful at all. I'd be +1 on removing this support and raise a TypeError instead. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 19:30:51 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sat, 03 Aug 2013 17:30:51 +0000 Subject: [issue17998] internal error in regular expression engine In-Reply-To: <1368803354.84.0.768428094886.issue17998@psf.upfronthosting.co.za> Message-ID: <1375551051.28.0.843524148904.issue17998@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: Sorry for the delay. I have committed a simple patch which fixes this bug. But I don't close the issue still because there are other related issues. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 19:39:59 2013 From: report at bugs.python.org (R. David Murray) Date: Sat, 03 Aug 2013 17:39:59 +0000 Subject: [issue17998] internal error in regular expression engine In-Reply-To: <1368803354.84.0.768428094886.issue17998@psf.upfronthosting.co.za> Message-ID: <1375551599.07.0.356100697633.issue17998@psf.upfronthosting.co.za> R. David Murray added the comment: This appears to have turned the buildbots red. ---------- nosy: +r.david.murray _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 19:44:39 2013 From: report at bugs.python.org (Tim Peters) Date: Sat, 03 Aug 2013 17:44:39 +0000 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375456931.04.0.558889166858.issue18629@psf.upfronthosting.co.za> Message-ID: <1375551879.77.0.26001855626.issue18629@psf.upfronthosting.co.za> Tim Peters added the comment: Well, a timedelta is a duration. timedelta // n is as close as possible to one n'th of that duration, but "rounding down" (if necessary) so that the result is representable as a timedelta. In the same way, if i and j are integers, i // j is as close as possible to one j'th of i, but "rounding down" (if necessary) so that the result is representable as an integer. Like: >>> from datetime import timedelta >>> timedelta(1) // 7 datetime.timedelta(0, 12342, 857142) >>> timedelta(1) - 7 * _ datetime.timedelta(0, 0, 6) >>> The last line shows the part truncated away: one seventh of a day is not representable as a timedetla. If `timedelta // int` rounded to the closest representable timedelta, it would return timedelta(0, 12342, 857143) instead. That's a little bigger than a seventh of a day: >>> timedelta(0, 12342, 857143) * 7 datetime.timedelta(1, 0, 1) It has nothing directly to do with days, hours, seconds ... it so happens that timedelta has microsecond resolution, so the closest representable approximations to one n'th of a timedelta most often have non-zero microsecond components. If timedelta had femtosecond resolution, they'd most often have non-zero femtosecond components ;-) ---------- nosy: +tim_one _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 19:50:54 2013 From: report at bugs.python.org (Jean-Paul Calderone) Date: Sat, 03 Aug 2013 17:50:54 +0000 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375456931.04.0.558889166858.issue18629@psf.upfronthosting.co.za> Message-ID: <1375552254.26.0.949469155399.issue18629@psf.upfronthosting.co.za> Jean-Paul Calderone added the comment: > I think that's a very obscure interpretation of floor division for timedeltas :-) Note - I don't care about this. I just want `timedelta / int` to do the same thing in Python 2.7 with __future__.division as `timedelta / int` does in Python 3. Please don't reject this because of some unrelated discussion about how floor division should be implemented for timedelta. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 20:13:39 2013 From: report at bugs.python.org (Roundup Robot) Date: Sat, 03 Aug 2013 18:13:39 +0000 Subject: [issue16067] UAC prompt for installation shows temporary file name In-Reply-To: <1348796990.29.0.204354546612.issue16067@psf.upfronthosting.co.za> Message-ID: <3c6tfB268JzPsH@mail.python.org> Roundup Robot added the comment: New changeset 797b1d13d16e by Martin v. L?wis in branch '3.3': Issue #16067: Add description into MSI file to replace installer's temporary name. http://hg.python.org/cpython/rev/797b1d13d16e New changeset 7d661f47f73b by Martin v. L?wis in branch 'default': Issue #16067: Merge with 3.3 http://hg.python.org/cpython/rev/7d661f47f73b ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 20:19:06 2013 From: report at bugs.python.org (Eli Bendersky) Date: Sat, 03 Aug 2013 18:19:06 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375553946.9.0.369864291532.issue18264@psf.upfronthosting.co.za> Eli Bendersky added the comment: Yes, AFAIU PyNumber_Long is the equivalent of Python-level int(obj). With other constructors of PyLong you are limited by long long (while Python integers may be arbitrarily large). Ethan - If you're still short on time I can pretty up this patch and put it for review with some tests. Let me know what you prefer. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 20:19:22 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Sat, 03 Aug 2013 18:19:22 +0000 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375456931.04.0.558889166858.issue18629@psf.upfronthosting.co.za> Message-ID: <1375553962.15.0.974596598789.issue18629@psf.upfronthosting.co.za> Alexander Belopolsky added the comment: There are two schools of thought here. One school (MAL and Mark) thinks of durations as real number of seconds. The other school (Tim and I) think of durations as integer number of resolution intervals. This is why I and Tim before me resisted adding true division of timedelta by a number and multiplication of timedelta by a float. Mark prevailed on that issue (see #1289118.) His expertise in floating point computing certainly helped designing and implementing these operations correctly. We still have a small quirk waiting to be ironed out (see #8860), but overall I am happy with the current state. This said, the datetime module carries a long legacy of being a pure integer arithmetics in a funny variable-radix notation. We can disagree on the utility of floor division as it is currently defined, but we cannot remove or change it in an incompatible way. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 20:20:47 2013 From: report at bugs.python.org (Roundup Robot) Date: Sat, 03 Aug 2013 18:20:47 +0000 Subject: [issue16741] `int()`, `float()`, etc think python strings are null-terminated In-Reply-To: <1356046641.74.0.314140910069.issue16741@psf.upfronthosting.co.za> Message-ID: <3c6tpQ3hZSzRN6@mail.python.org> Roundup Robot added the comment: New changeset ecc8512b427d by Serhiy Storchaka in branch '3.3': Issue #16741: Fix an error reporting in int(). http://hg.python.org/cpython/rev/ecc8512b427d New changeset 4fd48a807812 by Serhiy Storchaka in branch 'default': Issue #16741: Fix an error reporting in int(). http://hg.python.org/cpython/rev/4fd48a807812 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 20:21:52 2013 From: report at bugs.python.org (Ethan Furman) Date: Sat, 03 Aug 2013 18:21:52 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375554112.04.0.23010670019.issue18264@psf.upfronthosting.co.za> Ethan Furman added the comment: Thanks for the offer, Eli, but I almost have the tests done. :) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 20:24:41 2013 From: report at bugs.python.org (Roundup Robot) Date: Sat, 03 Aug 2013 18:24:41 +0000 Subject: [issue16067] UAC prompt for installation shows temporary file name In-Reply-To: <1348796990.29.0.204354546612.issue16067@psf.upfronthosting.co.za> Message-ID: <3c6ttx0wdJzS0x@mail.python.org> Roundup Robot added the comment: New changeset ee0bdc007a0f by Martin v. L?wis in branch '2.7': Issue #16067: Add description into MSI file to replace installer's temporary name. http://hg.python.org/cpython/rev/ee0bdc007a0f ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 20:25:30 2013 From: report at bugs.python.org (=?utf-8?q?Martin_v=2E_L=C3=B6wis?=) Date: Sat, 03 Aug 2013 18:25:30 +0000 Subject: [issue16067] UAC prompt for installation shows temporary file name In-Reply-To: <1348796990.29.0.204354546612.issue16067@psf.upfronthosting.co.za> Message-ID: <1375554330.04.0.938668422659.issue16067@psf.upfronthosting.co.za> Martin v. L?wis added the comment: Thanks for the report. This is now fixed on the active branches. ---------- nosy: +loewis resolution: -> fixed status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 20:29:35 2013 From: report at bugs.python.org (Larry Hastings) Date: Sat, 03 Aug 2013 18:29:35 +0000 Subject: [issue17998] internal error in regular expression engine In-Reply-To: <1368803354.84.0.768428094886.issue17998@psf.upfronthosting.co.za> Message-ID: <1375554575.39.0.249918694509.issue17998@psf.upfronthosting.co.za> Larry Hastings added the comment: This broke the test suite on all the 32-bit Linux buildbots. Sample output is here: http://buildbot.python.org/all/builders/x86%20Ubuntu%20Shared%203.x/builds/8349/steps/test/logs/stdio There's no obvious fix, and I want to cut 3.4a1 right about now, so I'm going to tag the version in trunk just before this checkin. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 20:33:00 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sat, 03 Aug 2013 18:33:00 +0000 Subject: [issue16741] `int()`, `float()`, etc think python strings are null-terminated In-Reply-To: <1356046641.74.0.314140910069.issue16741@psf.upfronthosting.co.za> Message-ID: <1375554780.74.0.253558087612.issue16741@psf.upfronthosting.co.za> Changes by Serhiy Storchaka : ---------- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 20:35:51 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Sat, 03 Aug 2013 18:35:51 +0000 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375456931.04.0.558889166858.issue18629@psf.upfronthosting.co.za> Message-ID: <1375554951.53.0.451762339009.issue18629@psf.upfronthosting.co.za> Alexander Belopolsky added the comment: > I just want `timedelta / int` to do the same thing in Python 2.7 > with __future__.division as `timedelta / int` does in Python 3. It other words you want to backport timedelta / int true division. I am afraid it is 3-4 years too late for this request, but I will let others make a call. Count me as -0. I usually prefer explicit error over an obscure bug. If we backport true division the -Qnew flag will be changing the meaning of timedelta / int very slightly: instead of rounding down it will round to nearest. There are cases where this difference is important. Furthemore, when people compare timedeltas in tests they rarely do it with precision tolerance. If you have a good test coverage change from floor to true division may break your tests. My recommendation is: replace timedelta / int with timedelta // int in your 2.x code. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 20:45:09 2013 From: report at bugs.python.org (Al Korgun) Date: Sat, 03 Aug 2013 18:45:09 +0000 Subject: [issue18642] enhancement for operator 'assert' In-Reply-To: <1375530787.73.0.318484624842.issue18642@psf.upfronthosting.co.za> Message-ID: <1375555509.25.0.525627652174.issue18642@psf.upfronthosting.co.za> Al Korgun added the comment: Mark Dickinson, #1 if dedug (and type check, respectively, as in this example, and 'raise') isn't needed we just need pyo >> Python won't execute those asserts at all that is convenient. if not isinstance(data, basestring): raise TypeError(...) - here we need additionally check debug variable, use wrapper or something. #2 'assert' is a good breakpoint (sorry, bad english. not sure if this is what I wanted to say) on its own. And to orientate on check & 'raise' we have to mark it somehow. #3 Well, the code is shorter, obviously. R. David Murray, yes, maybe confusing, but I can imagine many ways when it is very convenient. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 20:58:04 2013 From: report at bugs.python.org (Ethan Furman) Date: Sat, 03 Aug 2013 18:58:04 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375556284.55.0.153559485607.issue18264@psf.upfronthosting.co.za> Ethan Furman added the comment: Okay, patch attached with C code (thanks, Eli!), more python code, and some new tests. Only the `int` case is handled. ---------- Added file: http://bugs.python.org/file31141/issue18264.stoneleaf.01.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 20:59:34 2013 From: report at bugs.python.org (Al Korgun) Date: Sat, 03 Aug 2013 18:59:34 +0000 Subject: [issue18642] enhancement for operator 'assert' In-Reply-To: <1375530787.73.0.318484624842.issue18642@psf.upfronthosting.co.za> Message-ID: <1375556374.81.0.22615279146.issue18642@psf.upfronthosting.co.za> Al Korgun added the comment: Mark Dickinson, sorry, didn't answer the first questiuon. >> In your original message, is it your intention that the assert raises TypeError, or that it raises AssertionError? I suggest to add the ability to raise relevant (for specific part of code) exception on checking assertion. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 21:02:15 2013 From: report at bugs.python.org (Terry J. Reedy) Date: Sat, 03 Aug 2013 19:02:15 +0000 Subject: [issue18570] OverflowError in division: wrong message In-Reply-To: <1374924685.41.0.945479313268.issue18570@psf.upfronthosting.co.za> Message-ID: <1375556535.32.0.423870214607.issue18570@psf.upfronthosting.co.za> Terry J. Reedy added the comment: With that fixed, I am inclined to close this. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 21:05:24 2013 From: report at bugs.python.org (Tshepang Lekhonkhobe) Date: Sat, 03 Aug 2013 19:05:24 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375258820.22.0.0684222529612.issue18606@psf.upfronthosting.co.za> Message-ID: <1375556724.19.0.569495933091.issue18606@psf.upfronthosting.co.za> Changes by Tshepang Lekhonkhobe : ---------- nosy: +tshepang _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 21:09:30 2013 From: report at bugs.python.org (mrDoctorWho0 .) Date: Sat, 03 Aug 2013 19:09:30 +0000 Subject: [issue18642] enhancement for operator 'assert' In-Reply-To: <1375530787.73.0.318484624842.issue18642@psf.upfronthosting.co.za> Message-ID: <1375556970.0.0.908420024544.issue18642@psf.upfronthosting.co.za> mrDoctorWho0 . added the comment: Assert with this feature will make code simplest. Simplification isn't python way? Why don't add it in python? It's must be really useful. Sometimes its necessary, when need to catch specified exception. Its easier to search errors by type, not by error body ---------- nosy: +mrDoctorWho0.. _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 21:31:26 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Sat, 03 Aug 2013 19:31:26 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375258820.22.0.0684222529612.issue18606@psf.upfronthosting.co.za> Message-ID: <1375558286.11.0.0812868181552.issue18606@psf.upfronthosting.co.za> Alexander Belopolsky added the comment: Here is the use-case that was presented to support adding additional operations on timedelta objects: """ I'm conducting a series of observation experiments where I measure the duration of an event. I then want to do various statistical analysis such as computing the mean, median, etc. Originally, I tried using standard functions such as lmean from the stats.py package. However, these sorts of functions divide by a float at the end, causing them to fail on timedelta objects. Thus, I have to either write my own special functions, or convert the timedelta objects to integers first (then convert them back afterwards). """ (Daniel Stutzbach, in msg26267 on issue1289118.) The proposed statistics module does not support this use case: >>> mean([timedelta(1)]) Traceback (most recent call last): File "", line 1, in File "/Users/sasha/Work/cpython-ro/Lib/statistics.py", line 387, in mean total = sum(data) File "/Users/sasha/Work/cpython-ro/Lib/statistics.py", line 223, in sum total += x TypeError: unsupported operand type(s) for +=: 'int' and 'datetime.timedelta' >>> sum([timedelta(1)], timedelta(0)) Traceback (most recent call last): File "", line 1, in File "/Users/sasha/Work/cpython-ro/Lib/statistics.py", line 210, in sum raise TypeError('sum only accepts numbers') TypeError: sum only accepts numbers ---------- nosy: +agthorr _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 21:54:24 2013 From: report at bugs.python.org (R. David Murray) Date: Sat, 03 Aug 2013 19:54:24 +0000 Subject: [issue18642] enhancement for operator 'assert' In-Reply-To: <1375530787.73.0.318484624842.issue18642@psf.upfronthosting.co.za> Message-ID: <1375559664.67.0.174720682228.issue18642@psf.upfronthosting.co.za> R. David Murray added the comment: If your code is catching an exception generated by an assert statement, your code is using assert incorrectly. There is never any reason, as far as I can see, to catch an assert outside of a testing framework, and in a testing framework you definitely want to be catching an AssertionError when you are trying to catch an assert failing. Making it some other error would just confuse the testing framework. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 22:41:43 2013 From: report at bugs.python.org (Raymond Hettinger) Date: Sat, 03 Aug 2013 20:41:43 +0000 Subject: [issue18645] Add a configure option for performance guided optimization Message-ID: <1375562503.45.0.752070512413.issue18645@psf.upfronthosting.co.za> New submission from Raymond Hettinger: We can make it easier for users make custom, high-performance builds tailored to their actual use cases. Here's an example of how Firefox does it: https://developer.mozilla.org/en-US/docs/Building_with_Profile-Guided_Optimization ---------- components: Build messages: 194295 nosy: rhettinger priority: normal severity: normal status: open title: Add a configure option for performance guided optimization type: behavior versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 22:42:06 2013 From: report at bugs.python.org (Terry J. Reedy) Date: Sat, 03 Aug 2013 20:42:06 +0000 Subject: [issue18646] Improve tutorial entry on 'Lambda Forms'. Message-ID: <1375562526.59.0.207872880438.issue18646@psf.upfronthosting.co.za> New submission from Terry J. Reedy: [0. On mailing lists, 'lambda expression' is used rather than 'lambda form'. Docs use both. Consistency across docs is a broader issue than this one. So leave title alone for this one.] 1. (first sentence) "By popular demand, a few features commonly found in functional programming languages like Lisp have been added to Python." (in early Python 1!) I think this should just be deleted. See 4. below as a replacement. 2. " With the lambda keyword, small anonymous functions can be created." Change to "Small anonymous functions can be created with the lambda keyword." 3. change "Here?s a function that returns" to "This function returns" 3.5 add a sentence about the different between def and lambda (the name attribute. 4. Add sentences about the purposes of lambda. Add an example that illustrates passing functions. >>> pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')] >>> pairs.sort(key=lambda pair: pair[1]) >>> pairs [(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')] ---------- assignee: docs at python components: Documentation files: tut-lambda.diff keywords: patch messages: 194296 nosy: docs at python, terry.reedy priority: normal severity: normal stage: patch review status: open title: Improve tutorial entry on 'Lambda Forms'. type: behavior versions: Python 2.7, Python 3.3, Python 3.4 Added file: http://bugs.python.org/file31142/tut-lambda.diff _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 22:42:07 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sat, 03 Aug 2013 20:42:07 +0000 Subject: [issue18647] re.error: nothing to repeat Message-ID: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> New submission from Serhiy Storchaka: Now all doctests failed on 32-bit platforms due to the unlucky coincidence of my patch with at least two bugs which were hided before. SubPattern.getwidth() is wrong, it truncates resulted values to sys.maxsize (should be MAXREPEAT). As side effect of my patch (on 32-bit MAXREPEAT == sys.maxsize) it now returns correct value in some cases on 32-bit platforms. On other hand, the _simple() function in sre_compile.py checks if getwidth() returns (0, MAXREPEAT) and raise an error in such case. Perhaps it should guards against such patterns as '(x*)*' (but it doesn't guards against '(x*y?)*' or '(x*y*)*' and can raise false positive). Now getwidth() returns (0, MAXREPEAT) for '(x*y?)*' on 32-bit platforms (this is a correct result) and triggers the check. The doctest module uses regular expression pattern '(?:.*$\n?)*' which now causes an error. Definitely SubPattern.getwidth() is wrong and should be fixed. At least one of two, the _simple() function or doctest pattern should be fixed too. The simplest fix is disable the 'nothing to repeat' check. ---------- assignee: serhiy.storchaka components: Library (Lib), Regular Expressions messages: 194297 nosy: ezio.melotti, larry, mrabarnett, pitrou, serhiy.storchaka priority: normal severity: normal status: open title: re.error: nothing to repeat type: behavior versions: Python 2.7, Python 3.3, Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 22:48:44 2013 From: report at bugs.python.org (Roundup Robot) Date: Sat, 03 Aug 2013 20:48:44 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <3c6y576Rd7zRky@mail.python.org> Roundup Robot added the comment: New changeset c243896e12be by Serhiy Storchaka in branch '3.3': Issue #18647: Temporary disable the "nothing to repeat" check to make buildbots happy. http://hg.python.org/cpython/rev/c243896e12be New changeset 4faf9b73c3df by Serhiy Storchaka in branch 'default': Issue #18647: Temporary disable the "nothing to repeat" check to make buildbots happy. http://hg.python.org/cpython/rev/4faf9b73c3df ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 22:50:35 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sat, 03 Aug 2013 20:50:35 +0000 Subject: [issue17998] internal error in regular expression engine In-Reply-To: <1368803354.84.0.768428094886.issue17998@psf.upfronthosting.co.za> Message-ID: <1375563035.64.0.539202997971.issue17998@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: See issue18647. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 22:50:42 2013 From: report at bugs.python.org (Ethan Furman) Date: Sat, 03 Aug 2013 20:50:42 +0000 Subject: [issue18635] Enum sets _member_type_ to instantiated values but not the class In-Reply-To: <1375472056.62.0.564467694147.issue18635@psf.upfronthosting.co.za> Message-ID: <1375563042.12.0.385781082655.issue18635@psf.upfronthosting.co.za> Ethan Furman added the comment: Well, aside from not having a clue as to what Chris is trying to do, should we make _member_type_ public? The only reason I put it there was to aid introspection -- Enum does not use it. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 22:55:24 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sat, 03 Aug 2013 20:55:24 +0000 Subject: [issue17119] Integer overflow when passing large string or tuple to Tkinter In-Reply-To: <1359920139.05.0.774798858282.issue17119@psf.upfronthosting.co.za> Message-ID: <1375563324.47.0.177895146654.issue17119@psf.upfronthosting.co.za> Changes by Serhiy Storchaka : ---------- assignee: -> serhiy.storchaka _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 22:58:16 2013 From: report at bugs.python.org (Terry J. Reedy) Date: Sat, 03 Aug 2013 20:58:16 +0000 Subject: [issue18648] FP Howto and the PEP 8 lambda guildline Message-ID: <1375563496.73.0.458556999556.issue18648@psf.upfronthosting.co.za> New submission from Terry J. Reedy: Functional Programming HowTo, near the end, has a section Small functions and the lambda expression http://docs.python.org/3/howto/functional.html#small-functions-and-the-lambda-expression To illustrate, it starts with adder = lambda x, y: x+y print_assign = lambda name, value: name + '=' + str(value) which are now proscribed by PEP 8. "Always use a def statement instead of an assignment statement that binds a lambda expression directly to a name." The text goes on to give the def equivalents and to discourage lambdas. "Which alternative is preferable? That?s a style question; my usual course is to avoid using lambda." But I think the section should instead start with lambda examples that would be acceptable in the stdlib. ---------- messages: 194301 nosy: akuchling, terry.reedy priority: normal severity: normal stage: needs patch status: open title: FP Howto and the PEP 8 lambda guildline versions: Python 2.7, Python 3.3, Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 23:00:15 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sat, 03 Aug 2013 21:00:15 +0000 Subject: [issue17478] Tkinter's split() inconsistent for bytes and unicode strings In-Reply-To: <1363683519.76.0.514671428108.issue17478@psf.upfronthosting.co.za> Message-ID: <1375563615.52.0.782071067049.issue17478@psf.upfronthosting.co.za> Changes by Serhiy Storchaka : ---------- resolution: -> duplicate stage: -> committed/rejected status: open -> closed superseder: -> Tk.split() doesn't work with nested Unicode strings _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 23:16:13 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sat, 03 Aug 2013 21:16:13 +0000 Subject: [issue16741] `int()`, `float()`, etc think python strings are null-terminated In-Reply-To: <1356046641.74.0.314140910069.issue16741@psf.upfronthosting.co.za> Message-ID: <1375564573.11.0.228128147446.issue16741@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: There is a test in test_unicode which expects an UnicodeError for int('\ud800'). Now it fails. Should we fix a test or int()? ---------- resolution: fixed -> status: closed -> open _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 23:23:28 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Sat, 03 Aug 2013 21:23:28 +0000 Subject: [issue18629] future division breaks timedelta division by integer In-Reply-To: <1375456931.04.0.558889166858.issue18629@psf.upfronthosting.co.za> Message-ID: <1375565008.8.0.000373272390575.issue18629@psf.upfronthosting.co.za> Alexander Belopolsky added the comment: This issue is effectively a duplicate #1083 (see msg101281.) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 23:45:20 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Sat, 03 Aug 2013 21:45:20 +0000 Subject: [issue16741] `int()`, `float()`, etc think python strings are null-terminated In-Reply-To: <1356046641.74.0.314140910069.issue16741@psf.upfronthosting.co.za> Message-ID: <1375566320.36.0.894957975592.issue16741@psf.upfronthosting.co.za> Alexander Belopolsky added the comment: I'd say fix the test. Raising ValueError is correct in this case. UnicodeError was an implementation artifact. ---------- nosy: +belopolsky _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Aug 3 23:48:31 2013 From: report at bugs.python.org (Eli Bendersky) Date: Sat, 03 Aug 2013 21:48:31 +0000 Subject: [issue18635] Enum sets _member_type_ to instantiated values but not the class In-Reply-To: <1375472056.62.0.564467694147.issue18635@psf.upfronthosting.co.za> Message-ID: <1375566511.26.0.569723652717.issue18635@psf.upfronthosting.co.za> Eli Bendersky added the comment: -1 on making more internals public. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 00:00:28 2013 From: report at bugs.python.org (Eli Bendersky) Date: Sat, 03 Aug 2013 22:00:28 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375567228.62.0.278053355757.issue18264@psf.upfronthosting.co.za> Eli Bendersky added the comment: Posted a Rietveld code review ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 00:00:42 2013 From: report at bugs.python.org (Piotr Dobrogost) Date: Sat, 03 Aug 2013 22:00:42 +0000 Subject: [issue18649] list2cmdline function in subprocess module handles \" sequence wrong Message-ID: <1375567242.02.0.673942606159.issue18649@psf.upfronthosting.co.za> New submission from Piotr Dobrogost: According to the docstring of list2cmdline function in subprocess module the sequence of a backslash followed by a double quote mark should denote double quote mark in the output string. However it's not the case Python 2.7.4 (default, Apr 6 2013, 19:55:15) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import subprocess >>> print subprocess.list2cmdline(r'\"1|2\"') \ \" 1 | 2 \ \" The same behavior is in Python 3.3.1. See "On Windows, how can I protect arguments to shell scripts using Python 2.7 subprocess?"(http://stackoverflow.com/q/4970194/95735) question on Stack Overflow. ---------- components: Library (Lib) messages: 194307 nosy: Arve.Knudsen, exarkun, piotr.dobrogost, r.david.murray priority: normal severity: normal status: open title: list2cmdline function in subprocess module handles \" sequence wrong versions: Python 2.7, Python 3.3 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 00:03:09 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Sat, 03 Aug 2013 22:03:09 +0000 Subject: [issue8860] Rounding in timedelta constructor is inconsistent with that in timedelta arithmetics In-Reply-To: <1275323981.58.0.479401459542.issue8860@psf.upfronthosting.co.za> Message-ID: <1375567389.85.0.948369301117.issue8860@psf.upfronthosting.co.za> Alexander Belopolsky added the comment: I cleaned up the patch a little: 1. Removed now unused static round_to_long() function. 2. Removed commented out code. Mark, Any reason not to apply this? Do we need a NEWS entry for something like this? ---------- priority: low -> normal stage: test needed -> commit review versions: +Python 3.4 -Python 3.2 Added file: http://bugs.python.org/file31143/issue8860a.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 00:06:03 2013 From: report at bugs.python.org (Ned Deily) Date: Sat, 03 Aug 2013 22:06:03 +0000 Subject: [issue18650] intermittent test_pydoc failure on 3.4.0a1 Message-ID: <1375567563.7.0.0482703899635.issue18650@psf.upfronthosting.co.za> New submission from Ned Deily: Testing the 3.4.0a1 OS X 10.6 installer on OS X 10.8, I've now seen test_pydoc fail twice when the tests are run in order but then passing when the test is automatically rerun. I've not seen this failure previously. /usr/local/bin/python3.4 -m test -w -uall,-largefile== CPython 3.4.0a1 (v3.4.0a1:46535f65e7f3, Aug 3 2013, 14:03:34) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] == Darwin-12.5.0-x86_64-i386-32bit little-endian == /private/var/folders/42/hjgpmmxd2wbcrzh4r9vsk_6h0000gr/T/test_python_3742 Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1) [ 1/376] test_grammar ... [250/376] test_pyclbr [251/376] test_pydoc test test_pydoc failed -- Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/test/test_pydoc.py", line 624, in test_url_requests self.assertEqual(result, title, text) AssertionError: 'Pydoc: Error - ' != 'Pydoc: Index of Modules' - Pydoc: Error - + Pydoc: Index of Modules : Pydoc: Error -
Python 3.4.0a1 [v3.4.0a1:46535f65e7f3, GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
Darwin-12.5.0
 
 
Error
 

 
        KeyError: '/Users/pyi/Library/Python/3.4/lib/python/site-packages/setuptools-0.9.8-py3.4.egg'

[252/376/1] test_pyexpat ... Re-running failed tests in verbose mode Re-running test 'test_pydoc' in verbose mode ... test_url_requests (test.test_pydoc.PydocUrlHandlerTest) ... ok test_keywords (test.test_pydoc.TestHelper) ... ok ---------------------------------------------------------------------- Ran 25 tests in 2.253s OK ---------- components: Tests messages: 194309 nosy: ned.deily priority: normal severity: normal status: open title: intermittent test_pydoc failure on 3.4.0a1 versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 00:06:07 2013 From: report at bugs.python.org (Roundup Robot) Date: Sat, 03 Aug 2013 22:06:07 +0000 Subject: [issue16741] `int()`, `float()`, etc think python strings are null-terminated In-Reply-To: <1356046641.74.0.314140910069.issue16741@psf.upfronthosting.co.za> Message-ID: <3c6zpQ4GLJzSMR@mail.python.org> Roundup Robot added the comment: New changeset 7b023134ad83 by Serhiy Storchaka in branch '3.3': Issue #16741: Remove testing of implementation artifact. http://hg.python.org/cpython/rev/7b023134ad83 New changeset 1b4772ab420f by Serhiy Storchaka in branch 'default': Issue #16741: Remove testing of implementation artifact. http://hg.python.org/cpython/rev/1b4772ab420f ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 00:19:11 2013 From: report at bugs.python.org (Eli Bendersky) Date: Sat, 03 Aug 2013 22:19:11 +0000 Subject: [issue3591] elementtree tests do not include bytes handling In-Reply-To: <1219078669.04.0.473516144349.issue3591@psf.upfronthosting.co.za> Message-ID: <1375568351.73.0.166839751864.issue3591@psf.upfronthosting.co.za> Changes by Eli Bendersky : ---------- resolution: -> fixed stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 00:20:54 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Sat, 03 Aug 2013 22:20:54 +0000 Subject: [issue8860] Rounding in timedelta constructor is inconsistent with that in timedelta arithmetics In-Reply-To: <1275323981.58.0.479401459542.issue8860@psf.upfronthosting.co.za> Message-ID: <1375568454.54.0.910339472729.issue8860@psf.upfronthosting.co.za> Alexander Belopolsky added the comment: With the current patch we still have the following quirks: >>> timedelta(seconds=0.6112295) == timedelta(seconds=1)*0.6112295 False >>> timedelta(seconds=0.6112295) == timedelta(seconds=round(0.6112295, 6)) False This is not a reason to hold the patch, though. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 00:25:43 2013 From: report at bugs.python.org (Eli Bendersky) Date: Sat, 03 Aug 2013 22:25:43 +0000 Subject: [issue17372] provide pretty printer for xml.etree.ElementTree In-Reply-To: <1362640725.41.0.836381435016.issue17372@psf.upfronthosting.co.za> Message-ID: <1375568743.85.0.919328041677.issue17372@psf.upfronthosting.co.za> Eli Bendersky added the comment: I've noticed this is a duplicate of issue #14465. Closing it - let's continue the discussion there, when the time comes. ---------- resolution: -> duplicate stage: needs patch -> committed/rejected status: open -> closed superseder: -> xml.etree.ElementTree: add feature to prettify XML output _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 00:26:04 2013 From: report at bugs.python.org (Eli Bendersky) Date: Sat, 03 Aug 2013 22:26:04 +0000 Subject: [issue14465] xml.etree.ElementTree: add feature to prettify XML output In-Reply-To: <1333294084.01.0.984287406664.issue14465@psf.upfronthosting.co.za> Message-ID: <1375568764.48.0.948009410711.issue14465@psf.upfronthosting.co.za> Eli Bendersky added the comment: A patch exists in the duplicate #17372 ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 00:27:14 2013 From: report at bugs.python.org (Eli Bendersky) Date: Sat, 03 Aug 2013 22:27:14 +0000 Subject: [issue13368] Possible problem in documentation of module subprocess, method send_signal In-Reply-To: <1320722594.89.0.739080107592.issue13368@psf.upfronthosting.co.za> Message-ID: <1375568834.51.0.95637155017.issue13368@psf.upfronthosting.co.za> Eli Bendersky added the comment: Brian - gentle ping ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 00:31:14 2013 From: report at bugs.python.org (Arfrever Frehtes Taifersar Arahesis) Date: Sat, 03 Aug 2013 22:31:14 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375569074.5.0.196731062408.issue18647@psf.upfronthosting.co.za> Changes by Arfrever Frehtes Taifersar Arahesis : ---------- nosy: +Arfrever _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 01:07:48 2013 From: report at bugs.python.org (Tim Peters) Date: Sat, 03 Aug 2013 23:07:48 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375571268.84.0.857908285514.issue18647@psf.upfronthosting.co.za> Changes by Tim Peters : ---------- nosy: +tim_one _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 01:44:53 2013 From: report at bugs.python.org (Eli Bendersky) Date: Sat, 03 Aug 2013 23:44:53 +0000 Subject: [issue7990] xml.etree.cElementTree lacks full dir() on Element In-Reply-To: <1266856563.54.0.534391635456.issue7990@psf.upfronthosting.co.za> Message-ID: <1375573493.52.0.996658269343.issue7990@psf.upfronthosting.co.za> Eli Bendersky added the comment: Could you please refresh the patch for Python 3.3 and 3.4 (_elementtree went through many changes in 3.3)? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 02:49:02 2013 From: report at bugs.python.org (Roundup Robot) Date: Sun, 04 Aug 2013 00:49:02 +0000 Subject: [issue17011] ElementPath ignores different namespace mappings for the same path expression In-Reply-To: <1358838984.91.0.0315362873275.issue17011@psf.upfronthosting.co.za> Message-ID: <3c73QN3nGVz7LkL@mail.python.org> Roundup Robot added the comment: New changeset 854ded9135c2 by Eli Bendersky in branch '3.3': Issue #17011: Fix caching of xpath path when namespaces are present. http://hg.python.org/cpython/rev/854ded9135c2 New changeset ce0be0d03c0a by Eli Bendersky in branch 'default': Merge fix for Issue #17011 from 3.3 http://hg.python.org/cpython/rev/ce0be0d03c0a ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 02:49:28 2013 From: report at bugs.python.org (Eli Bendersky) Date: Sun, 04 Aug 2013 00:49:28 +0000 Subject: [issue17011] ElementPath ignores different namespace mappings for the same path expression In-Reply-To: <1358838984.91.0.0315362873275.issue17011@psf.upfronthosting.co.za> Message-ID: <1375577368.95.0.165568350275.issue17011@psf.upfronthosting.co.za> Eli Bendersky added the comment: Fixed. Thanks! ---------- resolution: -> fixed stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 02:54:49 2013 From: report at bugs.python.org (Eli Bendersky) Date: Sun, 04 Aug 2013 00:54:49 +0000 Subject: [issue17359] Mention "__main__.py" explicitly in command line docs In-Reply-To: <1362512425.64.0.937549165034.issue17359@psf.upfronthosting.co.za> Message-ID: <1375577689.27.0.355037377612.issue17359@psf.upfronthosting.co.za> Changes by Eli Bendersky : ---------- nosy: -eli.bendersky _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 03:00:05 2013 From: report at bugs.python.org (Eli Bendersky) Date: Sun, 04 Aug 2013 01:00:05 +0000 Subject: [issue18268] ElementTree.fromstring non-deterministically gives unicode text data In-Reply-To: <1371676914.3.0.530507394222.issue18268@psf.upfronthosting.co.za> Message-ID: <1375578005.8.0.679954416958.issue18268@psf.upfronthosting.co.za> Eli Bendersky added the comment: I'm not sure what the issue here is, exactly. Python 2.7 is known for implicit conversions between ascii and unicode, and this appears to be an artifact of your data. Note that Python 2.7 only gets fixes for serious bugs at this point. Can you reproduce this problem with Python 3.3? More generally, can you provide a small reproducer? Without this I don't think this is a constructive report, and will close the issue in a few days. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 03:02:49 2013 From: report at bugs.python.org (Eli Bendersky) Date: Sun, 04 Aug 2013 01:02:49 +0000 Subject: [issue17963] Deprecate the frame hack for implicitly getting module details In-Reply-To: <1368364153.58.0.131087315276.issue17963@psf.upfronthosting.co.za> Message-ID: <1375578169.55.0.210077917007.issue17963@psf.upfronthosting.co.za> Eli Bendersky added the comment: I'm (somewhat) back looking at this. Should the first step be sys.get_calling_module_name()? I can provide a patch. Re its name, perhaps the long name isn't that bad given that this is a rather obscure API. But suggestions for something shorter/better will be welcome. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 03:13:19 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Sun, 04 Aug 2013 01:13:19 +0000 Subject: [issue18648] FP Howto and the PEP 8 lambda guildline In-Reply-To: <1375563496.73.0.458556999556.issue18648@psf.upfronthosting.co.za> Message-ID: <1375578799.33.0.828536077651.issue18648@psf.upfronthosting.co.za> Alexander Belopolsky added the comment: I would just change "my usual course is to avoid using lambda" to "PEP 8 prescribes using def." Note that PEP 8 itself displays f = lambda x: 2*x as an example of what not to do. I see no problem with the current examples. ---------- nosy: +belopolsky _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 03:40:36 2013 From: report at bugs.python.org (Steven D'Aprano) Date: Sun, 04 Aug 2013 01:40:36 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375558286.11.0.0812868181552.issue18606@psf.upfronthosting.co.za> Message-ID: <51FDB0FE.205@pearwood.info> Steven D'Aprano added the comment: On 04/08/13 05:31, Alexander Belopolsky wrote: > > Alexander Belopolsky added the comment: > > Here is the use-case that was presented to support adding additional operations on timedelta objects: > > """ > I'm conducting a series of observation experiments where I > measure the duration of an event. I then want to do various > statistical analysis such as computing the mean, median, > etc. Originally, I tried using standard functions such as > lmean from the stats.py package. However, these sorts of > functions divide by a float at the end, causing them to fail > on timedelta objects. Thus, I have to either write my own > special functions, or convert the timedelta objects to > integers first (then convert them back afterwards). > """ (Daniel Stutzbach, in msg26267 on issue1289118.) > > The proposed statistics module does not support this use case: [...] > TypeError: sum only accepts numbers That's a nice use-case, but I'm not sure how to solve it, or whether it needs to be. I'm not going to add support for timedelta objects as a special-case. Once we start special-casing types, where will it end? At first I thought that registering timedelta as a numeric type would help, but that is a slightly dubious thing to do since timedelta doesn't support all numeric operations: py> datetime.timedelta(1, 1, 1)+2 Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for +: 'datetime.timedelta' and 'int' (What would that mean, anyway? Add two days, two seconds, or two milliseconds?) Perhaps timedelta objects should be enhanced to be (Integral?) numbers. In the meantime, there's a simple way to do this: py> from datetime import timedelta as td py> data = [td(2), td(1), td(3), td(4)] py> m = statistics.mean([x.total_seconds() for x in data]) py> m 216000.0 py> td(seconds=m) datetime.timedelta(2, 43200) And for standard deviation: py> s = statistics.stdev([x.total_seconds() for x in data]) py> td(seconds=s) datetime.timedelta(1, 25141, 920371) median works without any wrapper: py> statistics.median(data) datetime.timedelta(2, 43200) I'm now leaning towards "will not fix" for supporting timedelta objects. If they become proper numbers, then they should just work, and if they don't, supporting them just requires a tiny bit of extra code. However, I will add documentation and tests for them. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 03:52:56 2013 From: report at bugs.python.org (Christian Heimes) Date: Sun, 04 Aug 2013 01:52:56 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375258820.22.0.0684222529612.issue18606@psf.upfronthosting.co.za> Message-ID: <1375581176.82.0.514287640678.issue18606@psf.upfronthosting.co.za> Changes by Christian Heimes : ---------- nosy: +christian.heimes _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 03:53:07 2013 From: report at bugs.python.org (Nick Coghlan) Date: Sun, 04 Aug 2013 01:53:07 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1375567228.62.0.278053355757.issue18264@psf.upfronthosting.co.za> Message-ID: Nick Coghlan added the comment: It occurs to me that operator.index() (without a preceding type check) is likely the more ducktyping friendly option here. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 03:53:50 2013 From: report at bugs.python.org (Christian Heimes) Date: Sun, 04 Aug 2013 01:53:50 +0000 Subject: [issue7990] xml.etree.cElementTree lacks full dir() on Element In-Reply-To: <1266856563.54.0.534391635456.issue7990@psf.upfronthosting.co.za> Message-ID: <1375581230.8.0.579994012284.issue7990@psf.upfronthosting.co.za> Changes by Christian Heimes : ---------- nosy: +christian.heimes _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 03:55:30 2013 From: report at bugs.python.org (Roundup Robot) Date: Sun, 04 Aug 2013 01:55:30 +0000 Subject: [issue17902] Document that _elementtree C API cannot use custom TreeBuilder for iterparse or IncrementalParser In-Reply-To: <1367614578.64.0.34953241054.issue17902@psf.upfronthosting.co.za> Message-ID: <3c74v55gcnzStl@mail.python.org> Roundup Robot added the comment: New changeset a5a5ba4f71ad by Eli Bendersky in branch '3.3': Issue #17902: Clarify doc of ElementTree.iterparse http://hg.python.org/cpython/rev/a5a5ba4f71ad New changeset 96f45011957e by Eli Bendersky in branch 'default': Issue #17902: Clarify doc of ElementTree.iterparse and IncrementalParser http://hg.python.org/cpython/rev/96f45011957e ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 03:55:45 2013 From: report at bugs.python.org (Eli Bendersky) Date: Sun, 04 Aug 2013 01:55:45 +0000 Subject: [issue17902] Document that _elementtree C API cannot use custom TreeBuilder for iterparse or IncrementalParser In-Reply-To: <1367614578.64.0.34953241054.issue17902@psf.upfronthosting.co.za> Message-ID: <1375581345.82.0.234287163831.issue17902@psf.upfronthosting.co.za> Changes by Eli Bendersky : ---------- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 04:07:58 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Sun, 04 Aug 2013 02:07:58 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375258820.22.0.0684222529612.issue18606@psf.upfronthosting.co.za> Message-ID: <1375582078.36.0.764112705453.issue18606@psf.upfronthosting.co.za> Alexander Belopolsky added the comment: > Once we start special-casing types, where will it end? At the point where all stdlib types are special-cased. :-) > In the meantime, there's a simple way to do this: py> from datetime import timedelta as td py> data = [td(2), td(1), td(3), td(4)] py> m = statistics.mean([x.total_seconds() for x in data]) py> td(seconds=m) datetime.timedelta(2, 43200) Simple, but as simple ways go in this area not correct. Here is the right way: py> td.resolution * statistics.mean(d//td.resolution for d in data) datetime.timedelta(2, 43200) I wish I had a solution to make sum() work properly on timedeltas without special-casing. I thought that start could default to type(data[0])(0), but that would bring in strings. Maybe statistics.mean() should support non-numbers that support addition and division by a number? Will it be too confusing if mean() supports types that sum() does not? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 09:02:05 2013 From: report at bugs.python.org (Mark Dickinson) Date: Sun, 04 Aug 2013 07:02:05 +0000 Subject: [issue8860] Rounding in timedelta constructor is inconsistent with that in timedelta arithmetics In-Reply-To: <1275323981.58.0.479401459542.issue8860@psf.upfronthosting.co.za> Message-ID: <1375599725.43.0.408095725082.issue8860@psf.upfronthosting.co.za> Mark Dickinson added the comment: Alexander: applying this is fine by me. As a user-visible change, yes, I think it should have a Misc/NEWS entry. (It's too small a change to be worth mentioning in the 'whatsnew' documents though.) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 09:19:00 2013 From: report at bugs.python.org (Mark Dickinson) Date: Sun, 04 Aug 2013 07:19:00 +0000 Subject: [issue18642] enhancement for operator 'assert' In-Reply-To: <1375530787.73.0.318484624842.issue18642@psf.upfronthosting.co.za> Message-ID: <1375600740.77.0.340258215884.issue18642@psf.upfronthosting.co.za> Mark Dickinson added the comment: Okay, I'm closing this for now. Al Korgun and mrDoctorWho0 .: if you think this idea deserves wider discussion, you should feel free to bring it up again on the python-ideas mailing list; that's a better forum to discuss these sorts of language changes anyway (too few developers will look at any particular bug on the bug tracker; many more read python-ideas). It seems unlikely to me that the idea would receive widespread acceptance, but I may well be wrong. ---------- resolution: -> rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 09:21:43 2013 From: report at bugs.python.org (Ethan Furman) Date: Sun, 04 Aug 2013 07:21:43 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375600903.09.0.48656966351.issue18264@psf.upfronthosting.co.za> Ethan Furman added the comment: I don't understand. Type checks are already performed throughout the code (int, float, True, False, NaN, Inf, etc.). What will opereator.index buy us? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 09:30:24 2013 From: report at bugs.python.org (Mark Dickinson) Date: Sun, 04 Aug 2013 07:30:24 +0000 Subject: [issue18570] OverflowError in division: wrong message In-Reply-To: <1374924685.41.0.945479313268.issue18570@psf.upfronthosting.co.za> Message-ID: <1375601424.81.0.304513811112.issue18570@psf.upfronthosting.co.za> Mark Dickinson added the comment: > With that fixed, I am inclined to close this. Agreed. I'll try to find some time for a PEP at some point in the next few weeks. > I had thought of a set-mode function (method), but anticipate objection > to such modal action-at-distance behavior. Yes; I'm not a big fan of global state[*] either in general, but there aren't many other good options: specifying the mode to each operation individually would be painful and prevent natural use of infix operators, generally making code more unreadable. There *would* need to be some kind of set-mode function (or perhaps writable sys module attribute) as you suggest, but the context manager could be promoted as the recommended way to change the state in a manner that's reasonably safe and explicit. [*] We'd want it to be thread-local rather than global, of course. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 09:31:07 2013 From: report at bugs.python.org (Mark Dickinson) Date: Sun, 04 Aug 2013 07:31:07 +0000 Subject: [issue18570] OverflowError in division: wrong message In-Reply-To: <1374924685.41.0.945479313268.issue18570@psf.upfronthosting.co.za> Message-ID: <1375601467.54.0.730299988186.issue18570@psf.upfronthosting.co.za> Changes by Mark Dickinson : ---------- resolution: -> postponed status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 09:38:45 2013 From: report at bugs.python.org (Brendan O'Connor) Date: Sun, 04 Aug 2013 07:38:45 +0000 Subject: [issue11033] ElementTree.fromstring doesn't work with Unicode In-Reply-To: <1296173256.62.0.363094614198.issue11033@psf.upfronthosting.co.za> Message-ID: <1375601924.99.0.377402579068.issue11033@psf.upfronthosting.co.za> Brendan O'Connor added the comment: Sure, go ahead and close it. I was just trying to be helpful and report a bug in the Python standard library. I don't use Python 3.3 so cannot test it. ---------- nosy: +Brendan.OConnor _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 09:49:06 2013 From: report at bugs.python.org (Nick Coghlan) Date: Sun, 04 Aug 2013 07:49:06 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375602546.69.0.745119009172.issue18264@psf.upfronthosting.co.za> Nick Coghlan added the comment: The two "isinstance" checks that bother me are the ones for int and float. However, given that the JSON serialiser *already* includes those explicit checks, I now think it makes sense to just do the minimal fix of coercing subclasses to the base type for both of those cases, especially since such a change should be able to be ported to simplejson as well. Anything more elaborate (including making JSON explicitly enum aware, or else offering a new encoder that supports singledispatch) should be handled in a separate issue. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 10:07:20 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sun, 04 Aug 2013 08:07:20 +0000 Subject: [issue18151] Idlelib: update to "with open ... except OSError" (in 2.7, leave IOError) In-Reply-To: <1370538152.36.0.501706446334.issue18151@psf.upfronthosting.co.za> Message-ID: <1375603640.3.0.783921841198.issue18151@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: Here is a patch which replace the "open ... close" idiom to the "with open" idiom in IDLE. ---------- stage: commit review -> patch review Added file: http://bugs.python.org/file31144/idle_with_open.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 10:08:32 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sun, 04 Aug 2013 08:08:32 +0000 Subject: [issue18151] Idlelib: update to "with open ... except OSError" (in 2.7, leave IOError) In-Reply-To: <1370538152.36.0.501706446334.issue18151@psf.upfronthosting.co.za> Message-ID: <1375603712.83.0.639368446077.issue18151@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: Here is a patch which replace the "open ... close" idiom to the "with open" idiom in IDLE. ---------- Added file: http://bugs.python.org/file31145/idle_with_open.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 10:16:37 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sun, 04 Aug 2013 08:16:37 +0000 Subject: [issue14012] Misc tarfile fixes In-Reply-To: <1329235837.42.0.144867770777.issue14012@psf.upfronthosting.co.za> Message-ID: <1375604197.55.0.618937911221.issue14012@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: Here is updated for 3.4 patch. ---------- Added file: http://bugs.python.org/file31146/tarfile-misc-bugs-3.4.diff _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 10:37:10 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sun, 04 Aug 2013 08:37:10 +0000 Subject: [issue8865] select.poll is not thread safe In-Reply-To: <1275344415.87.0.130024541357.issue8865@psf.upfronthosting.co.za> Message-ID: <1375605430.15.0.944692441092.issue8865@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: Gregory, could you commit the patch or allow me to do this? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 10:56:17 2013 From: report at bugs.python.org (Mark Dickinson) Date: Sun, 04 Aug 2013 08:56:17 +0000 Subject: [issue17576] PyNumber_Index() is not int-subclass friendly (or operator.index() docos lie) In-Reply-To: <1364595911.19.0.826873230127.issue17576@psf.upfronthosting.co.za> Message-ID: <1375606577.3.0.541077109007.issue17576@psf.upfronthosting.co.za> Mark Dickinson added the comment: See the related python-dev discussion started by Mark Shannon here: http://mail.python.org/pipermail/python-dev/2013-March/125022.html and continuing well into April here: http://mail.python.org/pipermail/python-dev/2013-April/125042.html The consensus that emerged from that thread seems to be that calls to operator.index and to int() should always return something of exact type int. The attached patch: - Raises TypeError for implicit calls to nb_int that fail to return something of exact type int. (Results of direct calls to __int__ are not checked.) - Ensures that *all* conversions from a non-int to an int via nb_int make use of the nb_int slot, even for int subclasses. Prior to this patch, some of the PyLong_As... functions would bypass __int__ for int subclasses. - Adds a new private _PyLong_FromNbInt function to Objects/longobject.c, so that we have a single place for performing these conversions and making type checks, and refactors existing uses of the nb_int slot to go via this function. - Makes corresponding changes for nb_index, which should address the original bug report. I guess this may be too dangerous a change for Python 3.4. In that case, I propose raising warnings instead of TypeErrors for Python 3.4 and turning those into TypeErrors in Python 3.5. One other question: should direct calls to __int__ and __index__ also have their return values type-checked? That doesn't seem to happen at the moment for other magic methods (see below), so it would seem consistent to only do the type checking for interpreter-generated implicit calls to __int__ and __index__. Nick: any opinion? >>> class A: ... def __len__(self): return "a string" ... def __bool__(self): return "another string" ... >>> a = A() >>> a.__len__() 'a string' >>> a.__bool__() 'another string' >>> len(a) Traceback (most recent call last): File "", line 1, in TypeError: 'str' object cannot be interpreted as an integer >>> bool(a) Traceback (most recent call last): File "", line 1, in TypeError: __bool__ should return bool, returned str ---------- assignee: docs at python -> mark.dickinson components: +Interpreter Core -Documentation keywords: +patch nosy: +ncoghlan Added file: http://bugs.python.org/file31147/issue17576.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 12:07:06 2013 From: report at bugs.python.org (Matthias Klose) Date: Sun, 04 Aug 2013 10:07:06 +0000 Subject: [issue18651] test failures on KFreeBSD Message-ID: <1375610825.98.0.456814475805.issue18651@psf.upfronthosting.co.za> New submission from Matthias Klose: Some tests fail on KFreeBSD, attaching a first patch from Petr Salinger. see http://bugs.debian.org/708653 for further issues. Ronald, could you check if that this works for OSX too? ---------- components: Tests files: kfreebsd.diff keywords: patch messages: 194336 nosy: doko, ronaldoussoren priority: normal severity: normal status: open title: test failures on KFreeBSD versions: Python 3.3, Python 3.4 Added file: http://bugs.python.org/file31148/kfreebsd.diff _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 12:07:25 2013 From: report at bugs.python.org (Mark Dickinson) Date: Sun, 04 Aug 2013 10:07:25 +0000 Subject: [issue17576] PyNumber_Index() is not int-subclass friendly (or operator.index() docos lie) In-Reply-To: <1364595911.19.0.826873230127.issue17576@psf.upfronthosting.co.za> Message-ID: <1375610845.51.0.566366228358.issue17576@psf.upfronthosting.co.za> Mark Dickinson added the comment: New patch that replaces the TypeErrors with warnings and fixes a refleak in the original patch. ---------- Added file: http://bugs.python.org/file31149/issue17576_v2.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 12:08:55 2013 From: report at bugs.python.org (Hynek Schlawack) Date: Sun, 04 Aug 2013 10:08:55 +0000 Subject: =?utf-8?q?=5Bissue18652=5D_Add_a_=E2=80=9Cfirst=E2=80=9D_function_to_the_?= =?utf-8?q?stdlib?= Message-ID: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> New submission from Hynek Schlawack: Let met try to get you sold on adding the ?first? function I released on PyPI roughly a year ago: https://github.com/hynek/first It?s a very nice complement to functions like `any()` or itertools. I consists effectively of 9 lines of code but it proved extremely handy in production. *** It returns the first true value from an iterable or a default: >>> first([0, None, False, [], (), 42]) 42 >>> first([0, None, False, [], ()], default=42) 42 Additionally it also allows for a key function: >>> first([1, 1, 3, 4, 5], key=lambda x: x % 2 == 0) 4 *** First happens to be especially useful together with the re module: import re from first import first re1 = re.compile('b(.*)') re2 = re.compile('a(.*)') m = first(regexp.match('abc') for regexp in [re1, re2]) if not m: print('no match!') elif m.re is re1: print('re1', m.group(1)) elif m.re is re2: print('re2', m.group(1)) All the knee-jerk alternatives to it have some shortcomings: next(itertools.ifilter(None, (regexp.match('abc') for regexp in [re1, re2])), None) next((regexp.match('abc') for regexp in [re1, re2] if regexp.match('abc')), None) None of them is Pythonic and the second one even has to call match() twice, which is *not* a cheap method to call. Here the first version for comparison again: first(regexp.match('abc') for regexp in [re1, re2]) It doesn?t even exhaust the iterator if not necessary. *** I don?t cling to neither the name or the exact function signature (although it got polished with the help of several people, two of them core developers). I also don?t really care whether it gets added along of any() or put into itertools. I just know that I and several other people would appreciate to have such a handy function in the stdlib ? I even got an e-mail from OpenStack folks asking when it will be added because they would like to use it and there?s even a debian package by now: http://packages.debian.org/unstable/python-first There?s also this question on StackOverflow: http://stackoverflow.com/questions/1077307/why-is-there-no-firstiterable-built-in-function-in-python which is nice but doesn?t fix the subtleties like when there is no true value etc which makes it useless for production code and one has to write boilerplate code every single time. It was even one of five Python packages Lukasz Langa deemed worthy to be highlighted in his PyCon 2013 lightning talk: http://youtu.be/1vui-LupKJI?t=20m40s FWIW, SQL has a similar function called COALESCE ( https://en.wikipedia.org/wiki/Null_(SQL)#COALESCE ) which only handles NULL though. *** I?ll happily respond to any questions or concerns that may arise and supply a patch as soon as we agree on a place to add it. ---------- assignee: hynek components: Library (Lib) messages: 194338 nosy: hynek, lukasz.langa, ncoghlan, rhettinger priority: normal severity: normal status: open title: Add a ?first? function to the stdlib type: enhancement versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 12:23:13 2013 From: report at bugs.python.org (Roundup Robot) Date: Sun, 04 Aug 2013 10:23:13 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <3c7J8w3WfZz7LjN@mail.python.org> Roundup Robot added the comment: New changeset e2ba4592ce3a by Serhiy Storchaka in branch '2.7': Issue #18647: Temporary disable the "nothing to repeat" check to make buildbots happy. http://hg.python.org/cpython/rev/e2ba4592ce3a ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 12:24:34 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sun, 04 Aug 2013 10:24:34 +0000 Subject: [issue13612] xml.etree.ElementTree says unknown encoding of a regular encoding In-Reply-To: <1324026251.51.0.0968835446575.issue13612@psf.upfronthosting.co.za> Message-ID: <1375611874.73.0.740222320733.issue13612@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: Here is a patch for 2.7. ---------- Added file: http://bugs.python.org/file31150/expat_buffer_overflow-2.7.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 12:28:59 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sun, 04 Aug 2013 10:28:59 +0000 Subject: =?utf-8?q?=5Bissue18652=5D_Add_a_=E2=80=9Cfirst=E2=80=9D_function_to_the_?= =?utf-8?q?stdlib?= In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375612139.61.0.282526724055.issue18652@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: The function name looks a little misleading. I expected first([0, None, False, [], (), 42]) returns 0. ---------- nosy: +serhiy.storchaka _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 12:43:05 2013 From: report at bugs.python.org (=?utf-8?b?TWljaGHFgiBHw7Nybnk=?=) Date: Sun, 04 Aug 2013 10:43:05 +0000 Subject: [issue18201] distutils write into symlinks instead of replacing them In-Reply-To: <1371100735.33.0.721782392161.issue18201@psf.upfronthosting.co.za> Message-ID: <1375612985.88.0.0161748963567.issue18201@psf.upfronthosting.co.za> Micha? G?rny added the comment: Oh, sorry. I've looked throughout the code again and it seems that distutils is doing the right thing. It's setuptools/distribute that is broken. ---------- resolution: -> invalid status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 12:58:38 2013 From: report at bugs.python.org (Nick Coghlan) Date: Sun, 04 Aug 2013 10:58:38 +0000 Subject: =?utf-8?q?=5Bissue18652=5D_Add_a_=E2=80=9Cfirst=E2=80=9D_function_to_the_?= =?utf-8?q?stdlib?= In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375613918.37.0.222692945276.issue18652@psf.upfronthosting.co.za> Nick Coghlan added the comment: It's a direct counterpart to any() and all() - first([0, [], ()]) is None for the same reason that any([0, [], ()]) and all([0, [], ()]) are both False. If first returned the actual first item in the iterable (regardless of truth value), then it would just be "next" under a different name, which would be rather pointless. That said, if "first" is deemed too ambiguous, then I believe "filterednext" would be a reasonable more explicit name: >>> filterednext([0, None, False, [], (), 42]) 42 >>> filterednext([0, None, False, [], ()], default=42) 42 >>> filterednext([1, 1, 3, 4, 5], key=lambda x: x % 2 == 0) 4 >>> m = filterednext(regexp.match('abc') for regexp in [re1, re2]) I also believe itertools would be a more appropriate initial home than the builtins. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 12:58:43 2013 From: report at bugs.python.org (Piotr Dobrogost) Date: Sun, 04 Aug 2013 10:58:43 +0000 Subject: [issue13238] Add shell command helpers to subprocess module In-Reply-To: <1319176813.33.0.203455355645.issue13238@psf.upfronthosting.co.za> Message-ID: <1375613923.49.0.908105803244.issue13238@psf.upfronthosting.co.za> Changes by Piotr Dobrogost : ---------- nosy: +piotr.dobrogost _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 13:09:38 2013 From: report at bugs.python.org (=?utf-8?q?Martin_v=2E_L=C3=B6wis?=) Date: Sun, 04 Aug 2013 11:09:38 +0000 Subject: [issue17684] Skip tests in test_socket like testFDPassSeparate on OS X In-Reply-To: <1365563429.51.0.176752850468.issue17684@psf.upfronthosting.co.za> Message-ID: <1375614578.82.0.0498581931558.issue17684@psf.upfronthosting.co.za> Martin v. L?wis added the comment: Charles-Francois: why did you commit this to default only, and not to 3.3? (see also issue18651) ---------- nosy: +loewis _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 13:10:52 2013 From: report at bugs.python.org (=?utf-8?q?Martin_v=2E_L=C3=B6wis?=) Date: Sun, 04 Aug 2013 11:10:52 +0000 Subject: [issue18651] test failures on KFreeBSD In-Reply-To: <1375610825.98.0.456814475805.issue18651@psf.upfronthosting.co.za> Message-ID: <1375614652.42.0.712383481358.issue18651@psf.upfronthosting.co.za> Martin v. L?wis added the comment: Note that 3.4 will need a different patch, due to issue17684. ---------- nosy: +loewis _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 13:27:24 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sun, 04 Aug 2013 11:27:24 +0000 Subject: =?utf-8?q?=5Bissue18652=5D_Add_a_=E2=80=9Cfirst=E2=80=9D_function_to_the_?= =?utf-8?q?stdlib?= In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375615644.73.0.626898110146.issue18652@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: In this case it would be pointless too. It is just next(filter(key, iterable), default) Are you need a special function for combination of two builtins? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 13:29:25 2013 From: report at bugs.python.org (Nick Coghlan) Date: Sun, 04 Aug 2013 11:29:25 +0000 Subject: [issue17576] PyNumber_Index() is not int-subclass friendly (or operator.index() docos lie) In-Reply-To: <1364595911.19.0.826873230127.issue17576@psf.upfronthosting.co.za> Message-ID: <1375615765.09.0.934256182267.issue17576@psf.upfronthosting.co.za> Nick Coghlan added the comment: The deprecation warning version looks good to me. Something I'll mention explicitly (regarding the PyCon discussions that Eric mentioned above), is that we unfortunately couldn't do something like this for the various concrete APIs with overly permissive subclass checks. For those APIs, calling them directly was often the *right* thing for simple subtypes implemented in C to use to call up to the parent implementation. This case is different, as it's the *abstract* APIs that currently have the overly permissive checks. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 13:36:23 2013 From: report at bugs.python.org (Hynek Schlawack) Date: Sun, 04 Aug 2013 11:36:23 +0000 Subject: =?utf-8?q?=5Bissue18652=5D_Add_a_=E2=80=9Cfirst=E2=80=9D_function_to_the_?= =?utf-8?q?stdlib?= In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375616183.4.0.233060893218.issue18652@psf.upfronthosting.co.za> Hynek Schlawack added the comment: `filter()` exhausts the full iterator which is potentially very expensive ? like in conduction with regular expressions. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 13:38:39 2013 From: report at bugs.python.org (=?utf-8?q?Martin_v=2E_L=C3=B6wis?=) Date: Sun, 04 Aug 2013 11:38:39 +0000 Subject: =?utf-8?q?=5Bissue18652=5D_Add_a_=E2=80=9Cfirst=E2=80=9D_function_to_the_?= =?utf-8?q?stdlib?= In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375616319.28.0.683056445036.issue18652@psf.upfronthosting.co.za> Martin v. L?wis added the comment: I also think it should go to itertools. I also found the name "first" confusing, in particular since it means what Serhiy assumes in LISP, which might be familiar to people interested in functional list processing. Also, Ruby and Smalltalk use "first" in that sense. To add to the bike shedding, I propose "find_if" (from LISP), "coalesce" (from SQL), or "detect" (from Smalltalk). -1 on calling the filter function "key=". How about "pred=" (like all other itertools predicates) or "filter="? ---------- nosy: +loewis _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 13:38:46 2013 From: report at bugs.python.org (Nick Coghlan) Date: Sun, 04 Aug 2013 11:38:46 +0000 Subject: =?utf-8?q?=5Bissue18652=5D_Add_a_=E2=80=9Cfirst=E2=80=9D_function_to_the_?= =?utf-8?q?stdlib?= In-Reply-To: <1375615644.73.0.626898110146.issue18652@psf.upfronthosting.co.za> Message-ID: Nick Coghlan added the comment: Serhiy, Hynek covered the issue with the status quo in the original proposal.The existing alternative are painful to try and decipher by comparison with the named function: filterednext([0, None, False, [], (), 42]) vs next(filter(None, [0, None, False, [], (), 42])) filterednext([0, None, False, [], ()], default=42) vs next(filter(None, [0, None, False, [], (), 42]), 42) filterednext([1, 1, 3, 4, 5], key=lambda x: x % 2 == 0) vs next(filter(lambda x: x % 2 == 0, [1, 1, 3, 4, 5])) m = filterednext(regexp.match('abc') for regexp in [re1, re2]) vs m = next(filter(None, (regexp.match('abc') for regexp in [re1, re2]))) Hynek - the Python 3 filter is an iterator, so it works like the itertools.ifilter version in Python 2. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 13:41:34 2013 From: report at bugs.python.org (Hynek Schlawack) Date: Sun, 04 Aug 2013 11:41:34 +0000 Subject: =?utf-8?q?=5Bissue18652=5D_Add_a_=E2=80=9Cfirst=E2=80=9D_function_to_the_?= =?utf-8?q?stdlib?= In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375616494.65.0.976909182856.issue18652@psf.upfronthosting.co.za> Hynek Schlawack added the comment: Ah ok sorry. Anyhow, it?s just a very common idiom that should be easy and readable. As said, I?m not married to any names at all and would happily add a compatibility package to PyPI with the new names/parameters. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 13:49:38 2013 From: report at bugs.python.org (=?utf-8?q?Martin_v=2E_L=C3=B6wis?=) Date: Sun, 04 Aug 2013 11:49:38 +0000 Subject: =?utf-8?q?=5Bissue18652=5D_Add_a_=E2=80=9Cfirst=E2=80=9D_function_to_the_?= =?utf-8?q?stdlib?= In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375616978.47.0.912634231601.issue18652@psf.upfronthosting.co.za> Martin v. L?wis added the comment: Nick: that the code is difficult to decipher is really the fault of functional programming, which is inherently difficult to decipher (since last function applied is written first). Explicit iteration is easier to read. I would write Hynek's example as for r in (re1, re2): m = r.match('abc') if not m: print('No match) elif r is re1: print('re1', m.group(1)) elif r is re2: print('re1', m.group(1)) break # always This is only two additional lines, very Pythonic (IMO), and doesn't invoke match unnecessarily. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 13:50:16 2013 From: report at bugs.python.org (Nick Coghlan) Date: Sun, 04 Aug 2013 11:50:16 +0000 Subject: =?utf-8?q?=5Bissue18652=5D_Add_a_=E2=80=9Cfirst=E2=80=9D_function_to_the_?= =?utf-8?q?stdlib?= In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375617016.12.0.217582215461.issue18652@psf.upfronthosting.co.za> Nick Coghlan added the comment: Regarding the key parameter name, I believe this is closer to itertools.groupby (which uses "key=" as an optional argument, akin to min, max and sorted) than it is to filterfalse, dropwhile or takewhile (which use "pred" as the first positional argument) The only use of "pred" in the optional key argument sense appears to be the "quantify" recipe. +1 for itertools.coalesce, taking the name from SQL. It's designed to serve exactly the same purpose as COALESCE does there, doesn't risk confusion with next-like behaviour the way "first" does and hints strongly at the fact it is a reduction operation from an iterable to a single value. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 13:58:16 2013 From: report at bugs.python.org (Hynek Schlawack) Date: Sun, 04 Aug 2013 11:58:16 +0000 Subject: =?utf-8?q?=5Bissue18652=5D_Add_a_=E2=80=9Cfirst=E2=80=9D-like_function_to?= =?utf-8?q?_the_stdlib?= In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375617496.41.0.962119043333.issue18652@psf.upfronthosting.co.za> Hynek Schlawack added the comment: Martin, I don?t find the loop easier to read because you have to *remember* the `break` otherwise ?weird stuff happens?. Coalesce seems common enough, I would +1 on that too. ---------- title: Add a ?first? function to the stdlib -> Add a ?first?-like function to the stdlib _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 14:09:45 2013 From: report at bugs.python.org (Nick Coghlan) Date: Sun, 04 Aug 2013 12:09:45 +0000 Subject: [issue18652] Add itertools.coalesce In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375618185.88.0.0505194668165.issue18652@psf.upfronthosting.co.za> Nick Coghlan added the comment: (Updated the issue title to reflect the currently proposed name and location for the functionality) While I'm a fan of explicit iteration as well ("inside every reduce is a loop trying to get out"), I think the fact Martin's explicit loop is buggy (it will never match re2 as it always bails on the first iteration) helps make the case for coalesce. The correct explicit loop looks something like this: for r in (re1, re2): m = r.match('abc') if m is None: continue if r is re1: print('re1', m.group(1)) elif r is re2: print('re1', m.group(1)) break # Matched something else: print('No match') (Or the equivalent that indents the loop body further and avoids the continue statement) The coalesce version has a definite advantage in not needing a loop else clause to handle the "nothing matched" case: m = coalesce(regexp.match('abc') for regexp in [re1, re2]) if m is None: print('no match!') elif m.re is re1: print('re1', m.group(1)) elif m.re is re2: print('re2', m.group(1)) ---------- title: Add a ?first?-like function to the stdlib -> Add itertools.coalesce _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 14:14:26 2013 From: report at bugs.python.org (=?utf-8?q?Martin_v=2E_L=C3=B6wis?=) Date: Sun, 04 Aug 2013 12:14:26 +0000 Subject: [issue18652] Add itertools.coalesce In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375618466.68.0.538218853272.issue18652@psf.upfronthosting.co.za> Martin v. L?wis added the comment: Simplicity is in the eye of the beholder, yet... you need to remember the break when *writing* the code, so the loop might be more difficult to write (but then, I need to remember/lookup the function name and parameters for coalesce)... when reading the code, the break is already there, and easy to notice. With Nick's remark, it's even more obvious that it is difficult to write :-) If an unknown (to the reader) function is used, reading the code becomes actually difficult, since the reader either needs to guess what the function does, or look it up. Note that I'm not objecting the addition of the function (I'm neutral), just the claim that there are no simple alternatives. I'm neutral because it falls under the "not every two-line function needs to go into the standard library" rule; but then, if it is really popular, it helps readability if it is in the library (rather than duplicated by users). ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 14:15:47 2013 From: report at bugs.python.org (Piotr Dobrogost) Date: Sun, 04 Aug 2013 12:15:47 +0000 Subject: [issue1300] subprocess.list2cmdline doesn't do pipe symbols In-Reply-To: <1192729254.96.0.285794085895.issue1300@psf.upfronthosting.co.za> Message-ID: <1375618547.52.0.649224369432.issue1300@psf.upfronthosting.co.za> Piotr Dobrogost added the comment: >Maybe the solution is to make what I was trying to do easier without >fooling with the shell instead of playing the fool's game of trying to >improve the ability to deal with the shell so we can pass things >through it unnecessarily. You are too harsh for yourself :) We should be able to make use of shell easily the same way it's possible in other languages like Perl or Ruby. >It sure would be nice on Windows to have an equivalent of >list2cmdline() that works for the shell. I agree. See issue 13238 for a list of libraries which make is easier to use shell from Python. ---------- nosy: +piotr.dobrogost _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 14:35:20 2013 From: report at bugs.python.org (Roumen Petrov) Date: Sun, 04 Aug 2013 12:35:20 +0000 Subject: [issue18653] mingw-meta: build core modules Message-ID: <1375619720.06.0.766677441218.issue18653@psf.upfronthosting.co.za> New submission from Roumen Petrov: split of issue3871 - this is meta issue only for part related to build core. Remark: build of interpreter core is in issue17605 . Now split is: - 01 issue13756 : Python make fail on cygwin - 02 issue17219 : add current dir in library path if building python standard extensions - 03 issue6672 : Add Mingw recognition to pyport.h to allow building extensions - 04 issue18485 : configure for shared build - 05 issue18486 : dynamic loading support - 06 issue18487 : implement exec prefix - 07 issue18495 : ignore main program for frozen scripts - 08 issue18496 : setup exclude termios module - 09 issue18497 : setup _multiprocessing module - 10 issue18498 : setup select module - 11 issue18499 : setup _ctypes module with system libffi - 12 issue18500 : defect winsock2 and setup _socket module - 13 issue18630 : exclude unix only modules - 14 issue18631 : setup msvcrt and _winapi modules - 15 issue18632 : build extensions with GCC - 16 issue18633 : use Mingw32CCompiler as default compiler for mingw* build - 17 issue18634 : find import library - 18 issue18636 : setup _ssl module - 19 issue18637 : export _PyNode_SizeOf as PyAPI for parser module - 20 issue18638 : generalization of posix build in sysconfig.py - 21 issue18639 : avoid circular dependency from time module during native build of extentions - 22 issue18640 : generalization of posix build in distutils/sysconfig.py - 23 issue18641 : customize site - 24 after above patches user must regenerate configure script. Hints: a) at configure time define environment variable CPPFLAGS with minimum supported version like this "-DWINVER=0x501 -D_WIN32_WINNT=0x501 -DMS_COREDLL=1", i.e XP is now minimum. MS_COREDLL is required for ctype module b) at configure time define environment variable CCSHARED with minimum supported version like this: "-DWINVER=0x501 -D_WIN32_WINNT=0x501". Remark use same values as CPPFLAGS c) use --without-libm d) use --enable-shared e) use --with-system-ffi ---------- components: Build, Cross-Build, Extension Modules messages: 194358 nosy: rpetrov priority: normal severity: normal status: open title: mingw-meta: build core modules type: enhancement versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 14:39:05 2013 From: report at bugs.python.org (Mark Dickinson) Date: Sun, 04 Aug 2013 12:39:05 +0000 Subject: [issue18652] Add itertools.coalesce In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375619945.39.0.808704141651.issue18652@psf.upfronthosting.co.za> Mark Dickinson added the comment: [Nick] > Regarding the key parameter name, I believe this is closer to > itertools.groupby ... Isn't this mostly about the return type? `pred` is an indication that a boolean is being returned (or that the return value will be interpreted in a boolean context), while `key` is used for more general transformations. In that sense, `pred` makes more sense here. ---------- nosy: +mark.dickinson _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 14:42:13 2013 From: report at bugs.python.org (Eli Bendersky) Date: Sun, 04 Aug 2013 12:42:13 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375620133.77.0.43384807032.issue18264@psf.upfronthosting.co.za> Eli Bendersky added the comment: I also think that exchanging the explicit type checks by __index__ merits more thought and is outside the scope of this local fix. The proposed patch does not add any new type checks, but acts within the bounds of code for which the type is already established. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 14:43:01 2013 From: report at bugs.python.org (Nick Coghlan) Date: Sun, 04 Aug 2013 12:43:01 +0000 Subject: [issue18652] Add itertools.coalesce In-Reply-To: <1375619945.39.0.808704141651.issue18652@psf.upfronthosting.co.za> Message-ID: Nick Coghlan added the comment: Mark's rationale makes sense to me. I believe that would make the latest version of the proposed API (in the itertools module): def coalesce(iterable, default=None, pred=None): ... ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 14:51:47 2013 From: report at bugs.python.org (=?utf-8?q?Dan_S=C3=B8ndergaard?=) Date: Sun, 04 Aug 2013 12:51:47 +0000 Subject: [issue18624] Add alias for iso-8859-8-i which is the same as iso-8859-8 In-Reply-To: <1375398269.06.0.0330535739148.issue18624@psf.upfronthosting.co.za> Message-ID: <1375620707.42.0.0891847384207.issue18624@psf.upfronthosting.co.za> Dan S?ndergaard added the comment: Is it satisfactory to just add the -i and -e variants to ALIASES in charset.py? Or don't they qualify as "Aliases for other commonly-used names for character sets"? ---------- nosy: +das _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 15:05:00 2013 From: report at bugs.python.org (Roumen Petrov) Date: Sun, 04 Aug 2013 13:05:00 +0000 Subject: [issue18654] modernize mingw&cygwin compiler classes Message-ID: <1375621500.14.0.511859388859.issue18654@psf.upfronthosting.co.za> New submission from Roumen Petrov: Python mingw and cygwin compiler classes tests for outdated features. Also python code set some flags like zero optimization level and etc. that prevent users to build optimized python or even worse build to fail. This issue is part of split of issue3871 with clean-up and enhancements: - archive contain set of 10 patches - remove of outdated (15 years old !!!!) features one by one. - enhance unix compiler customization with mingw and cygwin compilers ---------- assignee: eric.araujo components: Build, Cross-Build, Distutils files: modernize-mingw+cygwin-compiler-class.tar.gz messages: 194363 nosy: eric.araujo, rpetrov, tarek priority: normal severity: normal status: open title: modernize mingw&cygwin compiler classes type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file31151/modernize-mingw+cygwin-compiler-class.tar.gz _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 15:10:41 2013 From: report at bugs.python.org (Roundup Robot) Date: Sun, 04 Aug 2013 13:10:41 +0000 Subject: [issue13612] xml.etree.ElementTree says unknown encoding of a regular encoding In-Reply-To: <1324026251.51.0.0968835446575.issue13612@psf.upfronthosting.co.za> Message-ID: <3c7Mt83ZfpzSXj@mail.python.org> Roundup Robot added the comment: New changeset b3efc140d8a6 by Eli Bendersky in branch '2.7': Issue #13612: Fix a buffer overflow in case of a multi-byte encoding. http://hg.python.org/cpython/rev/b3efc140d8a6 ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 15:11:32 2013 From: report at bugs.python.org (Eli Bendersky) Date: Sun, 04 Aug 2013 13:11:32 +0000 Subject: [issue13612] xml.etree.ElementTree says unknown encoding of a regular encoding In-Reply-To: <1324026251.51.0.0968835446575.issue13612@psf.upfronthosting.co.za> Message-ID: <1375621892.59.0.970233813371.issue13612@psf.upfronthosting.co.za> Eli Bendersky added the comment: Thanks, Serhiy. ---------- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 15:13:50 2013 From: report at bugs.python.org (Eli Bendersky) Date: Sun, 04 Aug 2013 13:13:50 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375622030.15.0.87312821702.issue18647@psf.upfronthosting.co.za> Eli Bendersky added the comment: Would it not be better to temporarily-fix the test rather than the code? ---------- nosy: +eli.bendersky _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 15:18:24 2013 From: report at bugs.python.org (Roumen Petrov) Date: Sun, 04 Aug 2013 13:18:24 +0000 Subject: [issue18654] modernize mingw&cygwin compiler classes In-Reply-To: <1375621500.14.0.511859388859.issue18654@psf.upfronthosting.co.za> Message-ID: <1375622304.14.0.842844631619.issue18654@psf.upfronthosting.co.za> Roumen Petrov added the comment: Proposed customization allow users to build extension module for windows with GNU compiler in all environments: - native with installed official build of python for windows - native either MSYS or CYGWIN enviroment and python build with GCC - cross-build in cygwin using official build of python for windows - cross-build in cygwin or linux with use of preset configuration from distribution - cross-build in linux and cross build python with GCC In addition patch allow user to build (native or cross) core modules with recent gnu compilers. ---------- keywords: +patch Added file: http://bugs.python.org/file31152/0011-MINGW-compiler-customize-mingw-cygwin-compilers.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 15:22:38 2013 From: report at bugs.python.org (Roumen Petrov) Date: Sun, 04 Aug 2013 13:22:38 +0000 Subject: [issue18653] mingw-meta: build core modules In-Reply-To: <1375619720.06.0.766677441218.issue18653@psf.upfronthosting.co.za> Message-ID: <1375622558.44.0.176475598462.issue18653@psf.upfronthosting.co.za> Roumen Petrov added the comment: This patch require "modernize mingw&cygwin compiler classes" now opened as separate issue18654 . ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 15:29:41 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sun, 04 Aug 2013 13:29:41 +0000 Subject: [issue18652] Add itertools.coalesce In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375622981.3.0.387078682534.issue18652@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: def coalesce(iterable, default=None, pred=None): return next(filter(pred, iterable), default) Are you sure you want add this one-line function to the itertools module rather then to recipes? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 15:34:33 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sun, 04 Aug 2013 13:34:33 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375623273.77.0.571238283172.issue18647@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: All doctests affected. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 15:40:02 2013 From: report at bugs.python.org (Roundup Robot) Date: Sun, 04 Aug 2013 13:40:02 +0000 Subject: [issue17684] Skip tests in test_socket like testFDPassSeparate on OS X In-Reply-To: <1365563429.51.0.176752850468.issue17684@psf.upfronthosting.co.za> Message-ID: <3c7NX13WlFz7Ljs@mail.python.org> Roundup Robot added the comment: New changeset b7d764807343 by Charles-Francois Natali in branch '3.3': Issue #17684: Fix some test_socket failures due to limited FD passing support http://hg.python.org/cpython/rev/b7d764807343 ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 15:42:35 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Sun, 04 Aug 2013 13:42:35 +0000 Subject: [issue17684] Skip tests in test_socket like testFDPassSeparate on OS X In-Reply-To: <1365563429.51.0.176752850468.issue17684@psf.upfronthosting.co.za> Message-ID: <1375623755.19.0.399226990034.issue17684@psf.upfronthosting.co.za> Charles-Fran?ois Natali added the comment: > Charles-Francois: why did you commit this to default only, and not > to 3.3? I overlooked it (apparently, the issue was tagged 3.4 only, and I didn't double-check that the code was present in 3.3 as well). Should be better now! ---------- versions: +Python 3.3 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 15:44:10 2013 From: report at bugs.python.org (Eli Bendersky) Date: Sun, 04 Aug 2013 13:44:10 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375623850.08.0.994035596655.issue18647@psf.upfronthosting.co.za> Eli Bendersky added the comment: Wonderfully terse, as usual. Can you be so kind to elaborate just a tiny bit more? Is the amount of doctests this affects so large that it's better to change the implementation? What are the plans for this "temporary" stage - is there an intention to fix the code "soon" and revert the disabling of this error check? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 15:49:14 2013 From: report at bugs.python.org (netrick) Date: Sun, 04 Aug 2013 13:49:14 +0000 Subject: [issue18655] GUI apps take long to launch on Windows Message-ID: <1375624154.73.0.44206476328.issue18655@psf.upfronthosting.co.za> New submission from netrick: On both Python 2 or 3, when you have GUI app (for example something in pygame or pyside or tk), when you launch it on Windows it takes about 4-6 seconds to display the Window for the first run. The next runs are faster, but only untill you reboot the PC. The thing is that on Linux even when launching the script for first time ever, the GUI Window shows instantly. Something how Python displays windows on Windows is wrong, there is something that causes the serious lag. You can see it very easy with IDLE. On Linux it launches instantly, on Windows XP on the same PC takes about 6 seconds to launch. I asked other people with different config and they have the same issue on Windows. ---------- components: Windows messages: 194374 nosy: netrick priority: normal severity: normal status: open title: GUI apps take long to launch on Windows type: performance versions: Python 2.7, Python 3.3 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 15:49:49 2013 From: report at bugs.python.org (Piotr Dobrogost) Date: Sun, 04 Aug 2013 13:49:49 +0000 Subject: [issue9148] os.execve puts process to background on windows In-Reply-To: <1278156575.44.0.771660264126.issue9148@psf.upfronthosting.co.za> Message-ID: <1375624189.67.0.560536146819.issue9148@psf.upfronthosting.co.za> Changes by Piotr Dobrogost : ---------- nosy: +piotr.dobrogost _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 15:51:15 2013 From: report at bugs.python.org (Roumen Petrov) Date: Sun, 04 Aug 2013 13:51:15 +0000 Subject: [issue17605] mingw-meta: build interpeter core In-Reply-To: <1364762524.12.0.901415822586.issue17605@psf.upfronthosting.co.za> Message-ID: <1375624275.39.0.4926247619.issue17605@psf.upfronthosting.co.za> Roumen Petrov added the comment: please follow build of core modules - issue18653 . ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 15:55:36 2013 From: report at bugs.python.org (Richard Oudkerk) Date: Sun, 04 Aug 2013 13:55:36 +0000 Subject: [issue18649] list2cmdline function in subprocess module handles \" sequence wrong In-Reply-To: <1375567242.02.0.673942606159.issue18649@psf.upfronthosting.co.za> Message-ID: <1375624536.33.0.907592090443.issue18649@psf.upfronthosting.co.za> Richard Oudkerk added the comment: Firstly, list2cmdline() takes a list as its argument, not a string: >>> import subprocess >>> print subprocess.list2cmdline([r'\"1|2\"']) \\\"1|2\\\" But the problem with passing arguments to a batch file is that cmd.exe parses arguments differently from how normal executables do. In particular, "|" is treated specially and "^" is used as an escape character. If you define test.bat as @echo off echo "%1" then subprocess.call(['test.bat', '1^|2']) prints "1|2" as expected. This is a duplicate of http://bugs.python.org/issue1300. ---------- nosy: +sbt resolution: -> invalid stage: -> committed/rejected status: open -> closed type: -> behavior _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 15:57:51 2013 From: report at bugs.python.org (Roumen Petrov) Date: Sun, 04 Aug 2013 13:57:51 +0000 Subject: [issue6335] Add support for mingw In-Reply-To: <1245849042.65.0.399048729588.issue6335@psf.upfronthosting.co.za> Message-ID: <1375624671.11.0.537455557017.issue6335@psf.upfronthosting.co.za> Roumen Petrov added the comment: I would like to config that path to this issue is one of those for issue3871 - my patch for 2.6/2.7 enhanced by "?? (sorry I forgot user :( ) " for 3.0 . Now as requested "all in one patch" is split and first set is listed in issue17605 "build interpeter core", second issue18653 "build core modules" plus modernization of mingw&cygwin compiler classes in scope of issue18654 . ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 15:58:51 2013 From: report at bugs.python.org (Matt Joiner) Date: Sun, 04 Aug 2013 13:58:51 +0000 Subject: [issue9148] os.execve puts process to background on windows In-Reply-To: <1278156575.44.0.771660264126.issue9148@psf.upfronthosting.co.za> Message-ID: <1375624731.19.0.00746921845303.issue9148@psf.upfronthosting.co.za> Changes by Matt Joiner : ---------- nosy: +anacrolix _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 16:00:14 2013 From: report at bugs.python.org (=?utf-8?q?Martin_v=2E_L=C3=B6wis?=) Date: Sun, 04 Aug 2013 14:00:14 +0000 Subject: [issue17684] Skip tests in test_socket like testFDPassSeparate on OS X In-Reply-To: <1365563429.51.0.176752850468.issue17684@psf.upfronthosting.co.za> Message-ID: <1375624814.7.0.708861560535.issue17684@psf.upfronthosting.co.za> Martin v. L?wis added the comment: Thanks! ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 16:19:52 2013 From: report at bugs.python.org (Roumen Petrov) Date: Sun, 04 Aug 2013 14:19:52 +0000 Subject: [issue9098] MSYS build fails with `S_IXGRP' undeclared In-Reply-To: <1277729031.36.0.263470334817.issue9098@psf.upfronthosting.co.za> Message-ID: <1375625992.14.0.676061575371.issue9098@psf.upfronthosting.co.za> Changes by Roumen Petrov : ---------- nosy: +rpetrov _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 16:20:18 2013 From: report at bugs.python.org (Roumen Petrov) Date: Sun, 04 Aug 2013 14:20:18 +0000 Subject: [issue4709] Mingw-w64 and python on windows x64 In-Reply-To: <1229849614.64.0.683517411932.issue4709@psf.upfronthosting.co.za> Message-ID: <1375626018.54.0.13473583101.issue4709@psf.upfronthosting.co.za> Changes by Roumen Petrov : ---------- nosy: +rpetrov _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 16:22:31 2013 From: report at bugs.python.org (Piotr Dobrogost) Date: Sun, 04 Aug 2013 14:22:31 +0000 Subject: [issue9148] os.execve puts process to background on windows In-Reply-To: <1278156575.44.0.771660264126.issue9148@psf.upfronthosting.co.za> Message-ID: <1375626151.15.0.817480810318.issue9148@psf.upfronthosting.co.za> Piotr Dobrogost added the comment: This is unexpected and makes people wonder what's going on. See http://stackoverflow.com/q/7004687/95735 and http://stackoverflow.com/q/7264571/95735. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 16:23:42 2013 From: report at bugs.python.org (Hynek Schlawack) Date: Sun, 04 Aug 2013 14:23:42 +0000 Subject: [issue18652] Add itertools.coalesce In-Reply-To: <1375622981.3.0.387078682534.issue18652@psf.upfronthosting.co.za> Message-ID: Hynek Schlawack added the comment: > def coalesce(iterable, default=None, pred=None): > return next(filter(pred, iterable), default) > > Are you sure you want add this one-line function to the itertools module rather then to recipes? Well, for many ? including me ? it would mean to have this one-line function in every other project or a PyPI dependency. I?m certain there are other short but useful functions in the stdlib. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 16:24:23 2013 From: report at bugs.python.org (Roumen Petrov) Date: Sun, 04 Aug 2013 14:24:23 +0000 Subject: [issue15315] Can't build Python extension with mingw32 on Windows In-Reply-To: <1341895923.16.0.599445307566.issue15315@psf.upfronthosting.co.za> Message-ID: <1375626263.73.0.611461841887.issue15315@psf.upfronthosting.co.za> Changes by Roumen Petrov : ---------- nosy: +rpetrov _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 16:39:06 2013 From: report at bugs.python.org (Piotr Dobrogost) Date: Sun, 04 Aug 2013 14:39:06 +0000 Subject: [issue18649] list2cmdline function in subprocess module handles \" sequence wrong In-Reply-To: <1375567242.02.0.673942606159.issue18649@psf.upfronthosting.co.za> Message-ID: <1375627146.6.0.162138756983.issue18649@psf.upfronthosting.co.za> Piotr Dobrogost added the comment: I think you're missing the point. The implementation is wrong as it does not do what documentation says which is "A double quotation mark preceded by a backslash is interpreted as a literal double quotation mark." How the output of list2cmdline interacts with the cmd.exe is another issue (It just happens here that if implementation of list2cmdline were in line with its documentation then there wouldn't be any subsequent problem with cmd.exe). Also issue 1300 is about escaping a pipe character (|) on the basis of how it's treated by cmd.exe and does not even refer to the docstring of list2cmdline function. ---------- resolution: invalid -> status: closed -> open _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 16:55:00 2013 From: report at bugs.python.org (Ramchandra Apte) Date: Sun, 04 Aug 2013 14:55:00 +0000 Subject: [issue18655] GUI apps take long to launch on Windows In-Reply-To: <1375624154.73.0.44206476328.issue18655@psf.upfronthosting.co.za> Message-ID: <1375628100.26.0.199439033384.issue18655@psf.upfronthosting.co.za> Ramchandra Apte added the comment: Can you provide a short script that reproduces this problem? AFAIK, Python doesn't display windows, the tcl/pygame libraries' C code creates the windows. ---------- nosy: +Ramchandra Apte _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 17:20:55 2013 From: report at bugs.python.org (Roumen Petrov) Date: Sun, 04 Aug 2013 15:20:55 +0000 Subject: [issue2445] Use The CygwinCCompiler Under Cygwin In-Reply-To: <1206117698.01.0.240143600903.issue2445@psf.upfronthosting.co.za> Message-ID: <1375629655.25.0.52757906739.issue2445@psf.upfronthosting.co.za> Roumen Petrov added the comment: Hi, Now issue18654 "modernize mingw&cygwin compiler classes" contain enhancement that could be reused by this issue: patch "0007-MINGW-compiler-cygwin-provides-its-own-C-runtime.patch " from archive , i.e. lets avoid change in get_msvcr() that return. Mingw is also impacted but is addresses in another patches. As separate patch is 'compiler customization' - more advanced version then proposed by Jeevan Varshney (jayvee) A separate issue18634 "find import library" address .dll.a suffix based on existing distutil functionality. Also issue18633 "Mingw32CCompiler as default compiler for mingw* build" adds same fixes from unix compiler class into Cygwin one - ref '# Chop off the drive' So with above I think that cygwin compiler could be switched back from unix to own. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 17:42:42 2013 From: report at bugs.python.org (Roundup Robot) Date: Sun, 04 Aug 2013 15:42:42 +0000 Subject: [issue18635] Enum sets _member_type_ to instantiated values but not the class In-Reply-To: <1375472056.62.0.564467694147.issue18635@psf.upfronthosting.co.za> Message-ID: <3c7RFZ0Qnxz7LjN@mail.python.org> Roundup Robot added the comment: New changeset b034418e840b by Ethan Furman in branch 'default': Close #18635: Move class level private attribute from instance to class. http://hg.python.org/cpython/rev/b034418e840b ---------- nosy: +python-dev resolution: -> fixed stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 17:42:49 2013 From: report at bugs.python.org (A. Jesse Jiryu Davis) Date: Sun, 04 Aug 2013 15:42:49 +0000 Subject: [issue18418] Thread.isAlive() sometimes True after fork In-Reply-To: <1375427255.41.0.51637343076.issue18418@psf.upfronthosting.co.za> Message-ID: A. Jesse Jiryu Davis added the comment: I'm back from a Zen retreat--no email!--will address your comments momentarily. On Fri, Aug 2, 2013 at 3:07 AM, Charles-Fran?ois Natali < report at bugs.python.org> wrote: > > Charles-Fran?ois Natali added the comment: > > I've posted another review (not sure you receive notifications). > > ---------- > > _______________________________________ > Python tracker > > _______________________________________ > ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 17:50:03 2013 From: report at bugs.python.org (R. David Murray) Date: Sun, 04 Aug 2013 15:50:03 +0000 Subject: [issue18624] Add alias for iso-8859-8-i which is the same as iso-8859-8 In-Reply-To: <1375398269.06.0.0330535739148.issue18624@psf.upfronthosting.co.za> Message-ID: <1375631403.72.0.503798944447.issue18624@psf.upfronthosting.co.za> R. David Murray added the comment: This issue is actually about adding the aliases to the codecs module. I'm not entirely sure at this point what the canonical character set name should be for email output (which is what the ALIASES table controls). ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 17:50:59 2013 From: report at bugs.python.org (A. Jesse Jiryu Davis) Date: Sun, 04 Aug 2013 15:50:59 +0000 Subject: [issue18418] Thread.isAlive() sometimes True after fork In-Reply-To: <1373408030.66.0.77258289483.issue18418@psf.upfronthosting.co.za> Message-ID: <1375631459.92.0.484362556263.issue18418@psf.upfronthosting.co.za> A. Jesse Jiryu Davis added the comment: New patch for 3.3 branch after Charles-Fran?ois's critique: use _enumerate() where appropriate, and join the test thread before finishing the test. ---------- Added file: http://bugs.python.org/file31153/issue18418-3.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 18:09:59 2013 From: report at bugs.python.org (netrick) Date: Sun, 04 Aug 2013 16:09:59 +0000 Subject: [issue18655] GUI apps take long to launch on Windows In-Reply-To: <1375624154.73.0.44206476328.issue18655@psf.upfronthosting.co.za> Message-ID: <1375632599.1.0.836067329197.issue18655@psf.upfronthosting.co.za> netrick added the comment: The simplest way to reproduce it is: 1) Reboot your PC 2) Launch IDLE (pre-installed with Python) 3) Look how long it takes to launch and then compare that with instant launch on Linux ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 18:12:55 2013 From: report at bugs.python.org (R. David Murray) Date: Sun, 04 Aug 2013 16:12:55 +0000 Subject: [issue18649] list2cmdline function in subprocess module handles \" sequence wrong In-Reply-To: <1375567242.02.0.673942606159.issue18649@psf.upfronthosting.co.za> Message-ID: <1375632775.42.0.0798050769629.issue18649@psf.upfronthosting.co.za> R. David Murray added the comment: This is a only a duplicate of issue 1300 in the sense that that issue points out that list2cmdline has nothing to do with passing/quoting strings for cmd.exe. list2cmdline is an internal function of the subprocess module. Its docstring documents the MS C quoting rules, *not* the input quoting rules. So its output is correct according to its doc string. If you pass ["test.bat", r'\"1|2\"'] to Popen using Richard's version of test.bat, you should get \"1|2\" as the output, which would be correct, since that is what you passed in as the argument to test.bat in the Popen call. The point is that the arguments specified in the list (shell=False) Popen call is supposed to be exactly what arguments get passed to the called program, and list2cmdline takes care of the MS C quoting to make that happen. (I don't use Windows much, so it is a bit of a pain for me to confirm the above example, but I'm nearly certain it will work as I say, modulo whatever quoting rule 'echo' uses for output.) ---------- components: +Benchmarks -Library (Lib) resolution: -> invalid status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 18:18:29 2013 From: report at bugs.python.org (R. David Murray) Date: Sun, 04 Aug 2013 16:18:29 +0000 Subject: [issue18649] list2cmdline function in subprocess module handles \" sequence wrong In-Reply-To: <1375567242.02.0.673942606159.issue18649@psf.upfronthosting.co.za> Message-ID: <1375633109.3.0.838343956296.issue18649@psf.upfronthosting.co.za> R. David Murray added the comment: The first line above is incomplete. I meant that issue 1300 is only a duplicate in the sense that it points out that list2cmdline implements the MS C quoting rules, *not* the cmd.exe quoting rules. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 18:21:56 2013 From: report at bugs.python.org (Richard Oudkerk) Date: Sun, 04 Aug 2013 16:21:56 +0000 Subject: [issue18649] list2cmdline function in subprocess module handles \" sequence wrong In-Reply-To: <1375567242.02.0.673942606159.issue18649@psf.upfronthosting.co.za> Message-ID: <1375633316.16.0.52863653465.issue18649@psf.upfronthosting.co.za> Richard Oudkerk added the comment: > I think you're missing the point. The implementation is wrong as it > does not do what documentation says which is "A double quotation mark > preceded by a backslash is interpreted as a literal double quotation > mark." That docstring describes how the string returned by list2cmdline() is interpreted by the MS C runtime. I assume you mean this bit: 3) A double quotation mark preceded by a backslash is interpreted as a literal double quotation mark. This looks correct to me: it implies that list2cmdline() must convert a double quotation mark to a double quotation mark preceded by a backslash. e.g. >>> print(subprocess.list2cmdline(['"'])) \" > How the output of list2cmdline interacts with the cmd.exe is another > issue (It just happens here that if implementation of list2cmdline were > in line with its documentation then there wouldn't be any subsequent > problem with cmd.exe). As I said, list2cmdline() behaves as expected. Whatever else happens, "|" must be escaped with "^" or else cmd will interpret it specially. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 18:31:00 2013 From: report at bugs.python.org (R. David Murray) Date: Sun, 04 Aug 2013 16:31:00 +0000 Subject: [issue18652] Add itertools.coalesce In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375633860.29.0.0162642167132.issue18652@psf.upfronthosting.co.za> R. David Murray added the comment: I'm not going to object to the name, since I see that it is used elsewhere in programming for the proposed meaning. But allow me to rant about the corruption of the English language here. To me, "coalesce" should involve a computation based on all of the elements of a list, not just picking out the first non-false value. ---------- nosy: +r.david.murray _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 18:39:09 2013 From: report at bugs.python.org (R. David Murray) Date: Sun, 04 Aug 2013 16:39:09 +0000 Subject: [issue18649] list2cmdline function in subprocess module handles \" sequence wrong In-Reply-To: <1375567242.02.0.673942606159.issue18649@psf.upfronthosting.co.za> Message-ID: <1375634349.39.0.801761082746.issue18649@psf.upfronthosting.co.za> R. David Murray added the comment: The list form of Popen should never be used with shell=True. It would be very good if someone would propose a 'cmd.exe quote' function for the stdlib. But both of these points don't have anything to do with this issue, as far as I can see :) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 18:52:25 2013 From: report at bugs.python.org (Berker Peksag) Date: Sun, 04 Aug 2013 16:52:25 +0000 Subject: [issue18484] No unit test for iso2time function from http.cookiejar module In-Reply-To: <1374079077.48.0.0605853512742.issue18484@psf.upfronthosting.co.za> Message-ID: <1375635145.81.0.0969913283295.issue18484@psf.upfronthosting.co.za> Changes by Berker Peksag : ---------- nosy: +berker.peksag _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 18:55:25 2013 From: report at bugs.python.org (Guido van Rossum) Date: Sun, 04 Aug 2013 16:55:25 +0000 Subject: [issue18656] setting function.__name__ doesn't affect repr() Message-ID: <1375635325.22.0.0227611021818.issue18656@psf.upfronthosting.co.za> New submission from Guido van Rossum: In Python 3.2 and earlier: >>> def f(): pass ... >>> f.__name__ = 'g' >>> f However in Python 3.3 and later, the last line shows 'f' instead of 'g'. ---------- components: Interpreter Core messages: 194394 nosy: gvanrossum priority: normal severity: normal status: open title: setting function.__name__ doesn't affect repr() type: behavior versions: Python 3.3, Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 19:02:50 2013 From: report at bugs.python.org (Mark Dickinson) Date: Sun, 04 Aug 2013 17:02:50 +0000 Subject: [issue18656] setting function.__name__ doesn't affect repr() In-Reply-To: <1375635325.22.0.0227611021818.issue18656@psf.upfronthosting.co.za> Message-ID: <1375635770.29.0.871009922958.issue18656@psf.upfronthosting.co.za> Mark Dickinson added the comment: I guess this is a direct consequence of PEP 3155 [1]. From the PEP: """ The repr() and str() of functions and classes is modified to use __qualname__ rather than __name__. """ [1] http://www.python.org/dev/peps/pep-3155/ ---------- nosy: +mark.dickinson, pitrou _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 19:11:13 2013 From: report at bugs.python.org (=?utf-8?b?SmVzw7pzIENlYSBBdmnDs24=?=) Date: Sun, 04 Aug 2013 17:11:13 +0000 Subject: [issue18656] setting function.__name__ doesn't affect repr() In-Reply-To: <1375635325.22.0.0227611021818.issue18656@psf.upfronthosting.co.za> Message-ID: <1375636273.47.0.64137214429.issue18656@psf.upfronthosting.co.za> Changes by Jes?s Cea Avi?n : ---------- nosy: +jcea _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 19:12:08 2013 From: report at bugs.python.org (STINNER Victor) Date: Sun, 04 Aug 2013 17:12:08 +0000 Subject: [issue18656] setting function.__name__ doesn't affect repr() In-Reply-To: <1375635325.22.0.0227611021818.issue18656@psf.upfronthosting.co.za> Message-ID: <1375636328.82.0.550513315433.issue18656@psf.upfronthosting.co.za> STINNER Victor added the comment: Python 3.4.0a0 (default:62658d9d8926+, Aug 1 2013, 23:05:18) [GCC 4.4.1 20090725 (Red Hat 4.4.1-2)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> def func(): pass ... >>> func >>> func.__qualname__="PEP 3155" >>> func ---------- nosy: +haypo _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 19:19:27 2013 From: report at bugs.python.org (Tim Peters) Date: Sun, 04 Aug 2013 17:19:27 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375636767.51.0.973205058605.issue18647@psf.upfronthosting.co.za> Tim Peters added the comment: Serhiy, I don't see the regexp '(?:.*$\n?)*' anywhere in doctest.py. Are you talking about the _EXAMPLE_RE regexp? That's the closest I see. If that's the case, the "nothing to repeat" error is incorrect: _EXAMPLE_RE also contains a negative lookahead assertion '(?![ ]*$)' to ensure that the later '.*$\n?' part never tries to match an empty string. That said, it takes some intelligence to realize that the negative lookahead assertion prevents repeating an empty match in this regexp, so it may not be easy to fix this false positive. A compromise may be to replace .*$\n? with .+$\n? | .*$\n Both branches then "obviously" consume at least one character. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 19:24:59 2013 From: report at bugs.python.org (Matt McClure) Date: Sun, 04 Aug 2013 17:24:59 +0000 Subject: [issue11798] Test cases not garbage collected after run In-Reply-To: <1302192957.51.0.450503345302.issue11798@psf.upfronthosting.co.za> Message-ID: <1375637099.36.0.102156383511.issue11798@psf.upfronthosting.co.za> Matt McClure added the comment: Michael Foord voidspace.org.uk> writes: > On 2 Aug 2013, at 19:19, Antoine Pitrou pitrou.net> wrote: > > The patch is basically ready for commit, except for a possible doc > > addition, no? > > Looks to be the case, reading the patch it looks fine. I'm currently on > holiday until Monday. If anyone is motivated to do the docs too and > commit that would be great. Otherwise I'll get to it on my return. It looks like the patch is based on what will become 3.4. Would backporting it to 2.7 be feasible? What's involved in doing so? I took a crack at the docs. I'm attaching an updated patch. ---------- nosy: +matthewlmclure _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 19:25:37 2013 From: report at bugs.python.org (STINNER Victor) Date: Sun, 04 Aug 2013 17:25:37 +0000 Subject: [issue8865] select.poll is not thread safe In-Reply-To: <1275344415.87.0.130024541357.issue8865@psf.upfronthosting.co.za> Message-ID: <1375637137.73.0.61232713083.issue8865@psf.upfronthosting.co.za> Changes by STINNER Victor : ---------- nosy: +haypo _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 19:25:57 2013 From: report at bugs.python.org (Matt McClure) Date: Sun, 04 Aug 2013 17:25:57 +0000 Subject: [issue11798] Test cases not garbage collected after run In-Reply-To: <1302192957.51.0.450503345302.issue11798@psf.upfronthosting.co.za> Message-ID: <1375637157.96.0.923474031023.issue11798@psf.upfronthosting.co.za> Changes by Matt McClure : Added file: http://bugs.python.org/file31154/11798-20130803-matthewlmcclure.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 19:27:02 2013 From: report at bugs.python.org (STINNER Victor) Date: Sun, 04 Aug 2013 17:27:02 +0000 Subject: [issue18651] test failures on KFreeBSD In-Reply-To: <1375610825.98.0.456814475805.issue18651@psf.upfronthosting.co.za> Message-ID: <1375637222.49.0.0722594377576.issue18651@psf.upfronthosting.co.za> Changes by STINNER Victor : ---------- nosy: +haypo _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 19:35:34 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sun, 04 Aug 2013 17:35:34 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375637734.65.0.522417415939.issue18647@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: The doctest engine uses a regexp which contains subpattern which now considered as illegal be the regexp engine (due to unlucky coincidence MAXREPEAT == sys.maxsize on 32-bit platforms). We should rewrite the _simple() function in the re module to be more smart. But if this assumption is correct and this subpattern is really dangerous we should also rewrite a regular expression in the doctest module. In any case we should fix SubPattern.getwidth() so that the behavior on 32-bit and 64-bit platforms should be the same. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 19:37:09 2013 From: report at bugs.python.org (Tim Peters) Date: Sun, 04 Aug 2013 17:37:09 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375637829.49.0.644900123275.issue18647@psf.upfronthosting.co.za> Tim Peters added the comment: Serhiy, I'm asking you to be very explicit about which regexp in doctest.py you're talking about. If you're talking about the _EXAMPLE_RE regexp, I already explained what's going on with that. If you're talking about some other regexp, I have no idea which one you're talking about. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 19:48:43 2013 From: report at bugs.python.org (Ethan Furman) Date: Sun, 04 Aug 2013 17:48:43 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375638523.87.0.312436314913.issue18264@psf.upfronthosting.co.za> Ethan Furman added the comment: This patch handles both float and int subclasses, and includes fixes/improvements from the review. ---------- Added file: http://bugs.python.org/file31155/issue18264.stoneleaf.02.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 20:05:27 2013 From: report at bugs.python.org (Madison May) Date: Sun, 04 Aug 2013 18:05:27 +0000 Subject: [issue18656] setting function.__name__ doesn't affect repr() In-Reply-To: <1375635325.22.0.0227611021818.issue18656@psf.upfronthosting.co.za> Message-ID: <1375639527.14.0.617787396713.issue18656@psf.upfronthosting.co.za> Madison May added the comment: Yup, here are the relevant lines of the diff for PEP 3155: @@ -568,7 +607,7 @@ func_repr(PyFunctionObject *op) { return PyUnicode_FromFormat("", - op->func_name, op); + op->func_qualname, op); } ---------- nosy: +madison.may _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 20:11:14 2013 From: report at bugs.python.org (Ethan Furman) Date: Sun, 04 Aug 2013 18:11:14 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375639874.31.0.371351313402.issue18264@psf.upfronthosting.co.za> Ethan Furman added the comment: Forgot to add float tests. Included in this patch. ---------- Added file: http://bugs.python.org/file31156/issue18264.stoneleaf.03.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 20:12:40 2013 From: report at bugs.python.org (Wes Turner) Date: Sun, 04 Aug 2013 18:12:40 +0000 Subject: [issue16692] Support TLS 1.1 and TLS 1.2 In-Reply-To: <1355592665.89.0.539973629387.issue16692@psf.upfronthosting.co.za> Message-ID: <1375639960.34.0.673518586683.issue16692@psf.upfronthosting.co.za> Wes Turner added the comment: http://docs.python.org/3.4/whatsnew/3.4.html#ssl re: Backporting to Python 2.7: maybe something like: backports.ssl (like backports.ssl_match_hostname) https://pypi.python.org/pypi/backports/ ---------- nosy: +westurner _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 20:22:59 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Sun, 04 Aug 2013 18:22:59 +0000 Subject: [issue11033] ElementTree.fromstring doesn't work with Unicode In-Reply-To: <1296173256.62.0.363094614198.issue11033@psf.upfronthosting.co.za> Message-ID: <1375640579.77.0.983892341274.issue11033@psf.upfronthosting.co.za> Changes by Alexander Belopolsky : ---------- status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 20:25:41 2013 From: report at bugs.python.org (Piotr Dobrogost) Date: Sun, 04 Aug 2013 18:25:41 +0000 Subject: [issue18649] list2cmdline function in subprocess module handles \" sequence wrong In-Reply-To: <1375567242.02.0.673942606159.issue18649@psf.upfronthosting.co.za> Message-ID: <1375640741.09.0.582900742409.issue18649@psf.upfronthosting.co.za> Piotr Dobrogost added the comment: The docstring starts with this statement "Translate a sequence of arguments into a command line string, using the same rules as the MS C runtime:" which clearly makes the impression that function list2cmdline uses the same rules as the MS C runtime. However after reading comments in this issue I believe I misunderstood the true meaning as the docstring is highly misleading. According to your comments, the word "using" was meant to pertain to the "command line string" (which is the output of the list2cmdline function) and _not_ to the translation phase itself. This makes sense taking into account the flow of events which is; a list of arguments -> list2cmdline -> CreateProcess. ---------- components: +Library (Lib) -Benchmarks resolution: invalid -> status: closed -> open _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 20:26:42 2013 From: report at bugs.python.org (Piotr Dobrogost) Date: Sun, 04 Aug 2013 18:26:42 +0000 Subject: [issue18649] list2cmdline function in subprocess module handles \" sequence wrong In-Reply-To: <1375567242.02.0.673942606159.issue18649@psf.upfronthosting.co.za> Message-ID: <1375640802.05.0.975039140965.issue18649@psf.upfronthosting.co.za> Changes by Piotr Dobrogost : ---------- resolution: -> invalid status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 20:31:38 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sun, 04 Aug 2013 18:31:38 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375641098.52.0.926313515714.issue18647@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: > Serhiy, I don't see the regexp '(?:.*$\n?)*' anywhere in doctest.py. Are you talking about the _EXAMPLE_RE regexp? That's the closest I see. Yes, it is. In my previous message I answered Eli. > If that's the case, the "nothing to repeat" error is incorrect: _EXAMPLE_RE also contains a negative lookahead assertion '(?![ ]*$)' to ensure that the later '.*$\n?' part never tries to match an empty string. Thank you for explanation. Unlucky the getwidth() method is not smart enough to detect that minimal length of matched string is not 0. We should made either the getwidth() method or the _simple() function (or both) more smart. > A compromise may be to replace > .*$\n? > with > .+$\n? | .*$\n I'm sure similar patterns are used in third-party code. We shouldn't break them, therefore we should fix _simple()/getwidth(). ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 20:32:12 2013 From: report at bugs.python.org (R. David Murray) Date: Sun, 04 Aug 2013 18:32:12 +0000 Subject: [issue18649] list2cmdline function in subprocess module handles \" sequence wrong In-Reply-To: <1375567242.02.0.673942606159.issue18649@psf.upfronthosting.co.za> Message-ID: <1375641132.2.0.440768711693.issue18649@psf.upfronthosting.co.za> R. David Murray added the comment: "Using the same rules as the MS C runtime" means that, given a sequence (list) of arguments, create a string that uses the same quoting that the MS C runtime uses. That is, if you have a sequence of arguments in a C program, and you want to call another windows program, you quote that sequence into a string using the same rules that list2cmdline uses. Can you suggest a wording for the doctring that would make this clearer? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 20:51:09 2013 From: report at bugs.python.org (Piotr Dobrogost) Date: Sun, 04 Aug 2013 18:51:09 +0000 Subject: [issue18649] list2cmdline function in subprocess module handles \" sequence wrong In-Reply-To: <1375567242.02.0.673942606159.issue18649@psf.upfronthosting.co.za> Message-ID: <1375642269.35.0.502219727052.issue18649@psf.upfronthosting.co.za> Piotr Dobrogost added the comment: Sure, something like "The purpose of this function is to construct a string which will be later interpreted by MS C runtime as denoting a sequence of arguments. Because of this the string is built in such a way as to preserve the original characters when interpreted by MS C runtime. For example a double quotation mark is preceded by the backslash so that MS C runtime would translate this back to the original double quotation mark according to its rules which are given below as a reference:" ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 20:52:54 2013 From: report at bugs.python.org (Roundup Robot) Date: Sun, 04 Aug 2013 18:52:54 +0000 Subject: [issue8860] Rounding in timedelta constructor is inconsistent with that in timedelta arithmetics In-Reply-To: <1275323981.58.0.479401459542.issue8860@psf.upfronthosting.co.za> Message-ID: <3c7WT15SJZzQr9@mail.python.org> Roundup Robot added the comment: New changeset f7c84ef35b00 by Alexander Belopolsky in branch 'default': Fixes #8860: Round half-microseconds to even in the timedelta constructor. http://hg.python.org/cpython/rev/f7c84ef35b00 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 20:53:48 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Sun, 04 Aug 2013 18:53:48 +0000 Subject: [issue8860] Rounding in timedelta constructor is inconsistent with that in timedelta arithmetics In-Reply-To: <1275323981.58.0.479401459542.issue8860@psf.upfronthosting.co.za> Message-ID: <1375642428.38.0.950057731582.issue8860@psf.upfronthosting.co.za> Changes by Alexander Belopolsky : ---------- resolution: -> fixed stage: commit review -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 21:31:04 2013 From: report at bugs.python.org (Madison May) Date: Sun, 04 Aug 2013 19:31:04 +0000 Subject: [issue18657] Remove duplicate ACKS entries Message-ID: <1375644664.94.0.607349544003.issue18657@psf.upfronthosting.co.za> New submission from Madison May: The title says it all. I used collections.Counter to check for duplicates in ACKS and cleaned up a few double entries. ---------- assignee: docs at python components: Documentation messages: 194410 nosy: docs at python, madison.may priority: normal severity: normal status: open title: Remove duplicate ACKS entries versions: Python 3.4, Python 3.5 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 21:34:22 2013 From: report at bugs.python.org (R. David Murray) Date: Sun, 04 Aug 2013 19:34:22 +0000 Subject: [issue18657] Remove duplicate ACKS entries In-Reply-To: <1375644664.94.0.607349544003.issue18657@psf.upfronthosting.co.za> Message-ID: <1375644862.39.0.664010166967.issue18657@psf.upfronthosting.co.za> R. David Murray added the comment: Did you intend to attach a patch? ---------- nosy: +r.david.murray _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 21:34:49 2013 From: report at bugs.python.org (Tim Peters) Date: Sun, 04 Aug 2013 19:34:49 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375644889.13.0.0630438600372.issue18647@psf.upfronthosting.co.za> Tim Peters added the comment: I'm afraid it's just too tricky for the code to deduce that a negative lookahead assertion can imply that a later match can't be empty. But I don't know how smart the re compilation code already is ;-) It occurs to me now that the doctest regexp could worm around this very easily, via replacing: .*$\n? with: .+$\n? The success of the negative lookahead assertion here doesn't _just_ imply that .*$\n? will match a non-empty string, it also implies that .+$ will succeed (and so also that .+$\n? will succeed). ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 21:38:43 2013 From: report at bugs.python.org (Madison May) Date: Sun, 04 Aug 2013 19:38:43 +0000 Subject: [issue18657] Remove duplicate ACKS entries In-Reply-To: <1375644664.94.0.607349544003.issue18657@psf.upfronthosting.co.za> Message-ID: <1375645123.32.0.63816213465.issue18657@psf.upfronthosting.co.za> Madison May added the comment: Now with 100% more patch. Thanks for the catch, David. ---------- keywords: +patch Added file: http://bugs.python.org/file31157/ACKS_duplicates.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 21:40:21 2013 From: report at bugs.python.org (Roundup Robot) Date: Sun, 04 Aug 2013 19:40:21 +0000 Subject: [issue18151] Idlelib: update to "with open ... except OSError" (in 2.7, leave IOError) In-Reply-To: <1370538152.36.0.501706446334.issue18151@psf.upfronthosting.co.za> Message-ID: <3c7XWn1f5zz7LjQ@mail.python.org> Roundup Robot added the comment: New changeset e450e85e2075 by Terry Jan Reedy in branch '3.3': Issue #18151: Replace remaining Idle 'open...close' pairs with 'with open'. http://hg.python.org/cpython/rev/e450e85e2075 New changeset 7f6661a90d02 by Terry Jan Reedy in branch '2.7': Issue #18151: Replace remaining Idle 'open...close' pairs with 'with open'. http://hg.python.org/cpython/rev/7f6661a90d02 ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 21:42:50 2013 From: report at bugs.python.org (Terry J. Reedy) Date: Sun, 04 Aug 2013 19:42:50 +0000 Subject: [issue18151] Idlelib: update to "with open ... except OSError" (in 2.7, leave IOError) In-Reply-To: <1370538152.36.0.501706446334.issue18151@psf.upfronthosting.co.za> Message-ID: <1375645370.16.0.935292262736.issue18151@psf.upfronthosting.co.za> Terry J. Reedy added the comment: Patch looked good, so I backported to 2.7 (attached, in case there are problems) and pushed. ---------- assignee: -> terry.reedy resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed Added file: http://bugs.python.org/file31158/idle_with_open-27.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 21:50:21 2013 From: report at bugs.python.org (Roundup Robot) Date: Sun, 04 Aug 2013 19:50:21 +0000 Subject: [issue18657] Remove duplicate ACKS entries In-Reply-To: <1375644664.94.0.607349544003.issue18657@psf.upfronthosting.co.za> Message-ID: <3c7XlJ3CgvzS7H@mail.python.org> Roundup Robot added the comment: New changeset 2ec323dadca2 by R David Murray in branch '3.3': #18657: remove duplicate entries from Misc/ACKS. http://hg.python.org/cpython/rev/2ec323dadca2 New changeset f4f81ebc3de9 by R David Murray in branch 'default': Merge: #18657: remove duplicate entries from Misc/ACKS. http://hg.python.org/cpython/rev/f4f81ebc3de9 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 21:50:47 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Sun, 04 Aug 2013 19:50:47 +0000 Subject: [issue10427] 24:00 Hour in DateTime In-Reply-To: <1289831880.43.0.381934582888.issue10427@psf.upfronthosting.co.za> Message-ID: <1375645847.24.0.898731550616.issue10427@psf.upfronthosting.co.za> Changes by Alexander Belopolsky : ---------- resolution: -> rejected stage: test needed -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 21:50:53 2013 From: report at bugs.python.org (R. David Murray) Date: Sun, 04 Aug 2013 19:50:53 +0000 Subject: [issue18657] Remove duplicate ACKS entries In-Reply-To: <1375644664.94.0.607349544003.issue18657@psf.upfronthosting.co.za> Message-ID: <1375645853.18.0.234539329669.issue18657@psf.upfronthosting.co.za> R. David Murray added the comment: Thanks, Madison. ---------- resolution: -> fixed stage: -> committed/rejected status: open -> closed type: -> behavior versions: +Python 3.3 -Python 3.5 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 21:58:06 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Sun, 04 Aug 2013 19:58:06 +0000 Subject: [issue1764286] inspect.getsource does not work with decorated functions Message-ID: <1375646286.59.0.463909604994.issue1764286@psf.upfronthosting.co.za> Changes by Alexander Belopolsky : ---------- assignee: belopolsky -> _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 22:05:32 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Sun, 04 Aug 2013 20:05:32 +0000 Subject: [issue10329] trace.py and unicode in Python 3 In-Reply-To: <1288969298.32.0.515004183172.issue10329@psf.upfronthosting.co.za> Message-ID: <1375646732.92.0.0768296400094.issue10329@psf.upfronthosting.co.za> Changes by Alexander Belopolsky : ---------- stage: test needed -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 22:14:30 2013 From: report at bugs.python.org (Daniel Stutzbach) Date: Sun, 04 Aug 2013 20:14:30 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375258820.22.0.0684222529612.issue18606@psf.upfronthosting.co.za> Message-ID: <1375647270.14.0.24258950211.issue18606@psf.upfronthosting.co.za> Daniel Stutzbach added the comment: As the person originally trying to take the mean of timedelta objects, I'm personally fine with the workaround of: py> m = statistics.mean([x.total_seconds() for x in data]) py> td(seconds=m) datetime.timedelta(2, 43200) At the time I was trying to take the mean of timedelta objects, even the total_seconds() method did not exist in the version of Python I was using. On the flip side, wouldn't sum() work on timedelta objects if you simply removed the "isinstance(start, numbers.Number)" check? ---------- nosy: +stutzbach _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 22:44:48 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sun, 04 Aug 2013 20:44:48 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375649088.09.0.562915876874.issue18647@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: Agree. Here is a partial patch which fixes getwidth() and doctest regexp. But I don't know how to fix _simple(). Perhaps we should permanently remove the "nothing to repeat" check. It guards only against '(.*)*', but there are other methods to make regexp matching exponential (i.e. '(.?.?)*'). ---------- keywords: +patch Added file: http://bugs.python.org/file31159/issue18647.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 22:50:08 2013 From: report at bugs.python.org (Guido van Rossum) Date: Sun, 04 Aug 2013 20:50:08 +0000 Subject: [issue18656] setting function.__name__ doesn't affect repr() In-Reply-To: <1375635325.22.0.0227611021818.issue18656@psf.upfronthosting.co.za> Message-ID: <1375649408.35.0.560469205439.issue18656@psf.upfronthosting.co.za> Guido van Rossum added the comment: Sorry. The actual problem reported was that the traceback uses the wrong name. I can still reproduce this in 3.4; attached is a repro. ---------- Added file: http://bugs.python.org/file31160/functools_wraps_oddity.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 22:58:43 2013 From: report at bugs.python.org (Benjamin Peterson) Date: Sun, 04 Aug 2013 20:58:43 +0000 Subject: [issue18656] setting function.__name__ doesn't affect repr() In-Reply-To: <1375635325.22.0.0227611021818.issue18656@psf.upfronthosting.co.za> Message-ID: <1375649923.96.0.200834620091.issue18656@psf.upfronthosting.co.za> Benjamin Peterson added the comment: That's because argument error messages use the code's co_name rather than the functions. (This is a dupe of another bug about this that I can't find.) ---------- nosy: +benjamin.peterson _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 23:02:27 2013 From: report at bugs.python.org (Mark Dickinson) Date: Sun, 04 Aug 2013 21:02:27 +0000 Subject: [issue18656] setting function.__name__ doesn't affect repr() In-Reply-To: <1375635325.22.0.0227611021818.issue18656@psf.upfronthosting.co.za> Message-ID: <1375650147.22.0.984501782476.issue18656@psf.upfronthosting.co.za> Mark Dickinson added the comment: http://bugs.python.org/issue4322 ? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 23:05:14 2013 From: report at bugs.python.org (Benjamin Peterson) Date: Sun, 04 Aug 2013 21:05:14 +0000 Subject: [issue18656] setting function.__name__ doesn't affect repr() In-Reply-To: <1375635325.22.0.0227611021818.issue18656@psf.upfronthosting.co.za> Message-ID: <1375650314.57.0.705588577259.issue18656@psf.upfronthosting.co.za> Benjamin Peterson added the comment: Exactly ---------- resolution: -> duplicate status: open -> closed superseder: -> function with modified __name__ uses original name when there's an arg error _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 23:05:51 2013 From: report at bugs.python.org (Benjamin Peterson) Date: Sun, 04 Aug 2013 21:05:51 +0000 Subject: [issue4322] function with modified __name__ uses original name when there's an arg error In-Reply-To: <1226645058.7.0.820357853432.issue4322@psf.upfronthosting.co.za> Message-ID: <1375650351.04.0.243377842761.issue4322@psf.upfronthosting.co.za> Benjamin Peterson added the comment: I think fixing this is a valid request. ---------- resolution: invalid -> status: closed -> open _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 23:08:03 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sun, 04 Aug 2013 21:08:03 +0000 Subject: [issue18652] Add itertools.coalesce In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375650483.17.0.00705482182738.issue18652@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: > Well, for many ? including me ? it would mean to have this one-line function in every other project or a PyPI dependency. But why you want to have a separate function instead of just use two builtins? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 23:09:08 2013 From: report at bugs.python.org (Tim Peters) Date: Sun, 04 Aug 2013 21:09:08 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375650548.93.0.0911639721758.issue18647@psf.upfronthosting.co.za> Tim Peters added the comment: Matching an empty string an unbounded number of times isn't a case of exponential runtime, it's a case of infinite runtime, unless the regexp internals are smart enough to cut the search off (I don't know enough about re's internals to know whether it's smart enough to do so). So it's worth catching at compile time if it can be caught. Alas, regexps are so complicated I doubt it's possible to do so without false positives or false negatives short of major effort. For now, at least the doctest part of the patch should be harmless ;-) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 23:15:42 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sun, 04 Aug 2013 21:15:42 +0000 Subject: [issue5845] rlcompleter should be enabled automatically In-Reply-To: <1240702039.68.0.55843541961.issue5845@psf.upfronthosting.co.za> Message-ID: <1375650942.56.0.714690407485.issue5845@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: Do you know that the readline module first force rebind of TAB to insert-tab? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 23:25:26 2013 From: report at bugs.python.org (Tim Peters) Date: Sun, 04 Aug 2013 21:25:26 +0000 Subject: [issue18652] Add itertools.coalesce In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375651526.41.0.839819504509.issue18652@psf.upfronthosting.co.za> Tim Peters added the comment: FWIW, I like this. It would be a nice addition to the itertools module. +1 The `key` argument should be renamed to `pred`, as others have said. As to the name, I like "first_true". Does what it says. Plain "first" is misleading, and "coalesce" is both inscrutable and nearly impossible to spell ;-) ---------- nosy: +tim_one _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 23:26:54 2013 From: report at bugs.python.org (Hynek Schlawack) Date: Sun, 04 Aug 2013 21:26:54 +0000 Subject: [issue18652] Add itertools.coalesce In-Reply-To: <1375650483.17.0.00705482182738.issue18652@psf.upfronthosting.co.za> Message-ID: <0E8EEC86-CB04-43EB-9697-E5985999C865@ox.cx> Hynek Schlawack added the comment: > But why you want to have a separate function instead of just use two builtins? This question has been answered twice now, once from Nick ? please refer above. It's a clunky and error-prone solution to a common problem. Maybe you can't emphasize because it's not a common problem to you but that doesn't make it less useful. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 23:27:16 2013 From: report at bugs.python.org (Michael Foord) Date: Sun, 04 Aug 2013 21:27:16 +0000 Subject: [issue11798] Test cases not garbage collected after run In-Reply-To: <1302192957.51.0.450503345302.issue11798@psf.upfronthosting.co.za> Message-ID: <1375651636.14.0.937422789581.issue11798@psf.upfronthosting.co.za> Michael Foord added the comment: This smells like a new feature to me (it's certainly a fairly significant change in behaviour) and isn't appropriate for backporting to 2.7. It can however go into unittest2. I agree with David that a destructive iteration using pop is more likely to cause backwards-compatibility issues. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 23:39:44 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sun, 04 Aug 2013 21:39:44 +0000 Subject: [issue18563] No unit test for yiq to rgb and rgb to yiq converting functions In-Reply-To: <1374856220.88.0.555143792121.issue18563@psf.upfronthosting.co.za> Message-ID: <1375652384.07.0.594665909204.issue18563@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: This is superseded by issue14323. ---------- resolution: -> duplicate stage: patch review -> committed/rejected status: open -> closed superseder: -> Normalize math precision in RGB/YIQ conversion _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 23:44:37 2013 From: report at bugs.python.org (Michael Foord) Date: Sun, 04 Aug 2013 21:44:37 +0000 Subject: [issue11798] Test cases not garbage collected after run In-Reply-To: <1302192957.51.0.450503345302.issue11798@psf.upfronthosting.co.za> Message-ID: <1375652677.75.0.210814557582.issue11798@psf.upfronthosting.co.za> Michael Foord added the comment: The doc patch looks good, thanks Matt. I'll read it through properly before committing. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 23:52:22 2013 From: report at bugs.python.org (=?utf-8?b?SmVzw7pzIENlYSBBdmnDs24=?=) Date: Sun, 04 Aug 2013 21:52:22 +0000 Subject: [issue4322] function with modified __name__ uses original name when there's an arg error In-Reply-To: <1226645058.7.0.820357853432.issue4322@psf.upfronthosting.co.za> Message-ID: <1375653142.85.0.503925716579.issue4322@psf.upfronthosting.co.za> Changes by Jes?s Cea Avi?n : ---------- nosy: +jcea stage: committed/rejected -> needs patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Aug 4 23:52:41 2013 From: report at bugs.python.org (=?utf-8?b?SmVzw7pzIENlYSBBdmnDs24=?=) Date: Sun, 04 Aug 2013 21:52:41 +0000 Subject: [issue4322] function with modified __name__ uses original name when there's an arg error In-Reply-To: <1226645058.7.0.820357853432.issue4322@psf.upfronthosting.co.za> Message-ID: <1375653161.62.0.889486092852.issue4322@psf.upfronthosting.co.za> Changes by Jes?s Cea Avi?n : ---------- versions: +Python 3.4 -Python 3.0 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 00:23:34 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Sun, 04 Aug 2013 22:23:34 +0000 Subject: [issue14323] Normalize math precision in RGB/YIQ conversion In-Reply-To: <1331831977.5.0.174772346075.issue14323@psf.upfronthosting.co.za> Message-ID: <1375655014.68.0.334448880497.issue14323@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: Here is a patch which implements the FCC version of RGB/YIQ conversion. ---------- Added file: http://bugs.python.org/file31161/colorsys_yiq_fcc.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 00:38:06 2013 From: report at bugs.python.org (Matthew Barnett) Date: Sun, 04 Aug 2013 22:38:06 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375655886.64.0.650319732849.issue18647@psf.upfronthosting.co.za> Matthew Barnett added the comment: Suppose you have a repeated pattern, such as "(?:...)*" or "(?:...){0,100}". If, after matching the subpattern, the text position hasn't changed, and none of the capture groups have changed, then there has been no progress, and the subpattern will be matched again with no more progress, unless the maximum count has been reached, at which point it'll continue with the remainder of the pattern. If there's no minimum count, then the subpattern will be matched repeatedly forever. Therefore, what a repeat should do is not to attempt any more iterations if the text position hasn't changed and none of the capture groups have changed. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 01:01:47 2013 From: report at bugs.python.org (Ben Finney) Date: Sun, 04 Aug 2013 23:01:47 +0000 Subject: [issue12645] test.support. import_fresh_module - incorrect doc In-Reply-To: <1375360954.84.0.771246589439.issue12645@psf.upfronthosting.co.za> Message-ID: <20130804230031.GB6856@benfinney.id.au> Ben Finney added the comment: On 01-Aug-2013, Eli Bendersky wrote: > Ben, would you like to provide an updated patch? Unfortunately, contributions are not accepted under the Apache Software Foundation License (as I had thought), but also require assigning extra privileges to the Python Software Foundation under a special agreement. I'm not able to do this in good conscience, so it seems the Python Software Foundation will reject my contribution. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 01:14:49 2013 From: report at bugs.python.org (Nick Coghlan) Date: Sun, 04 Aug 2013 23:14:49 +0000 Subject: [issue18652] Add itertools.coalesce In-Reply-To: <1375651526.41.0.839819504509.issue18652@psf.upfronthosting.co.za> Message-ID: Nick Coghlan added the comment: A wild timbot appears! :) Tim Peters added the comment: > As to the name, I like "first_true". Does what it says. Plain "first" is misleading, and "coalesce" is both inscrutable and nearly impossible to spell ;-) A fair point, although skipping the underscore ("firsttrue" or "nexttrue") would arguably be more consistent with other itertools names. I guess it's over to Raymond now as module maintainer for a yes/docs recipe/no response, and if one of the first two, the exact name used. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 01:15:01 2013 From: report at bugs.python.org (Tim Peters) Date: Sun, 04 Aug 2013 23:15:01 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375658101.08.0.84474177093.issue18647@psf.upfronthosting.co.za> Tim Peters added the comment: Matthew, yes, I agree that a regexp engine can be coded to be robust against unboundedly repeated matching of an empty string. I don't know whether Python's current engine is so coded. It's easy to trick the 2.7 engine into accepting regexps that do try to match an empty string endlessly, but across all I've tried none show "infinite loop" (or even slow) behavior. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 01:40:31 2013 From: report at bugs.python.org (Matthew Barnett) Date: Sun, 04 Aug 2013 23:40:31 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375659631.57.0.387013443587.issue18647@psf.upfronthosting.co.za> Matthew Barnett added the comment: Python's current regex engine isn't so coded. That's the reason for the up-front check. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 01:46:34 2013 From: report at bugs.python.org (Tim Peters) Date: Sun, 04 Aug 2013 23:46:34 +0000 Subject: [issue18652] Add itertools.coalesce In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375659994.62.0.284910996846.issue18652@psf.upfronthosting.co.za> Tim Peters added the comment: > skipping the underscore ("firsttrue" or "nexttrue") > would arguably be more consistent with other itertools names. Like izip_longest and combinations_with_replacement? ;-) I care about readability here more than consistency with the bulk of itertools names. "first" ends with "t" and "true" begins with "t", which makes "firsttrue" an eyesore. "first_true" strikes me as very easy to read, spell, remember and understand. Offhand I don't know what "nexttrue" is supposed to mean (like "if that's supposed to mean the first true iterate, why didn't they say 'first' instead of 'next'?"). ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 01:54:31 2013 From: report at bugs.python.org (Tim Peters) Date: Sun, 04 Aug 2013 23:54:31 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375660471.42.0.388715986593.issue18647@psf.upfronthosting.co.za> Tim Peters added the comment: > Python's current regex engine isn't so coded. That's > the reason for the up-front check. It's peculiar then that nobody noticed before now that the check was so badly broken ;-) Offhand, do you have an example that displays bad behavior in 2.7? I'm curious because I didn't find one after half an hour of trying. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 02:04:45 2013 From: report at bugs.python.org (Nick Coghlan) Date: Mon, 05 Aug 2013 00:04:45 +0000 Subject: [issue18652] Add itertools.first_true (return first true item in iterable) In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375661085.94.0.825989015274.issue18652@psf.upfronthosting.co.za> Nick Coghlan added the comment: I concede Tim's point about itertools already using underscores where it improves readability of a name :) So, the latest state of the proposal is to add the following, preferably directly to the module, but at least as a recipe in the itertools docs: def first_true(iterable, default=None, pred=None): """Returns the first true item in the iterable If no such item is found, returns *default* If *pred* is not None, returns the first item for which pred(item) is true. """ return next(filter(pred, iterable), default) ---------- title: Add itertools.coalesce -> Add itertools.first_true (return first true item in iterable) _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 02:17:28 2013 From: report at bugs.python.org (=?utf-8?q?Jo=C3=A3o_Bernardo?=) Date: Mon, 05 Aug 2013 00:17:28 +0000 Subject: [issue18078] threading.Condition to allow notify on a specific waiter In-Reply-To: <1369712419.12.0.434704480843.issue18078@psf.upfronthosting.co.za> Message-ID: <1375661848.79.0.00989851660229.issue18078@psf.upfronthosting.co.za> Jo?o Bernardo added the comment: I've been thinking about returning a list on "wait_for_any", but that way you will not be able to implement "wait_for" using it! "wait_for" will return False on timeouts while "wait_for_any" will return a list with some conditions(evaluates to True). Also, "wait_for" will show the result of the predicate when there's no timeout. It may clash with the boolean value of the list in some cases. Suggestions? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 03:48:09 2013 From: report at bugs.python.org (Raymond Hettinger) Date: Mon, 05 Aug 2013 01:48:09 +0000 Subject: [issue18078] threading.Condition to allow notify on a specific waiter In-Reply-To: <1369712419.12.0.434704480843.issue18078@psf.upfronthosting.co.za> Message-ID: <1375667289.1.0.153864522958.issue18078@psf.upfronthosting.co.za> Raymond Hettinger added the comment: FWIW, I don't support adding this functionality. I don't see precedents for Condition Variables behaving this way in other languages. Also, I don't think it is worth the added complexity, learning curve, and maintenance burden. Condition variables are used as primitive for other mutexes and I think we ought to keep them somewhat simple. If someone wants to notify a specific waiter, then they have other options such as using a separate condition variable that shares the same underlying lock (much as the code in the queue module does). That approach is easy to reason about. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 03:48:24 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Mon, 05 Aug 2013 01:48:24 +0000 Subject: [issue18658] Mercurial CPython log ticket link is broken Message-ID: <1375667304.35.0.50370358918.issue18658@psf.upfronthosting.co.za> New submission from Vajrasky Kok: Go to http://hg.python.org/cpython. All ticket links (number preceded by #), such as #18567 refer to bugs in jython. For example: 5 hours ago R David Murray Merge: #18657: remove duplicate entries from Misc/ACKS.default tip 5 hours ago R David Murray #18657: remove duplicate entries from Misc/ACKS.3.3 The "Merge" link refers to correct place. But "#18657" goes to http://bugs.jython.org/issue18657. It happens to *all ticket links*. ---------- messages: 194444 nosy: vajrasky priority: normal severity: normal status: open title: Mercurial CPython log ticket link is broken _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 04:08:23 2013 From: report at bugs.python.org (Terry J. Reedy) Date: Mon, 05 Aug 2013 02:08:23 +0000 Subject: [issue14323] Normalize math precision in RGB/YIQ conversion In-Reply-To: <1331831977.5.0.174772346075.issue14323@psf.upfronthosting.co.za> Message-ID: <1375668503.5.0.650552449635.issue14323@psf.upfronthosting.co.za> Terry J. Reedy added the comment: Can you add a reference for the coefficients? I believe def test_main(): test.support.run_unittest(ColorsysTest) if __name__ == "__main__": test_main has been and is being replaced in other test files with if __name__ == "__main__": unittest.main and should be here. This should get a short What's New entry in the library section, something like colorsys: "The number of digits in the coefficients for the RGB -- YIQ conversions have been expanded so that they match the FCC NTSC versions. The change in results should be less than 1% and may better match results found elsewhere." (You claim about the current rounding is not exactly correct. While .28*g rounds .277 rather than .274, the current .52*g rounds the non-FCC .523 rather than the FCC .5251. So I avoided making the claim in the suggested entry. It is not important.) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 07:12:36 2013 From: report at bugs.python.org (Ned Deily) Date: Mon, 05 Aug 2013 05:12:36 +0000 Subject: [issue18658] Mercurial CPython log ticket link is broken In-Reply-To: <1375667304.35.0.50370358918.issue18658@psf.upfronthosting.co.za> Message-ID: <1375679556.26.0.323057123728.issue18658@psf.upfronthosting.co.za> Ned Deily added the comment: Sorry, I'm not seeing this behavior. Is it still happening for you? ---------- nosy: +ned.deily _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 07:19:00 2013 From: report at bugs.python.org (Ronald Oussoren) Date: Mon, 05 Aug 2013 05:19:00 +0000 Subject: [issue18651] test failures on KFreeBSD In-Reply-To: <1375610825.98.0.456814475805.issue18651@psf.upfronthosting.co.za> Message-ID: <1375679940.83.0.641525774891.issue18651@psf.upfronthosting.co.za> Ronald Oussoren added the comment: I don't expect problems on OSX because of this. However: the patch replaces support.anticipate_failure by unittest.skipIf and that seems wrong to me. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 07:26:07 2013 From: report at bugs.python.org (Ronald Oussoren) Date: Mon, 05 Aug 2013 05:26:07 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375258820.22.0.0684222529612.issue18606@psf.upfronthosting.co.za> Message-ID: <1375680367.53.0.253377262217.issue18606@psf.upfronthosting.co.za> Ronald Oussoren added the comment: As noted before statistics.sum seems to have the same functionality as math.fsum. Statistics.add_partial, which does the majority of the work, also references the same cookbook recipe as the math.fsum documentation. IMHO statistics.sum should be removed. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 07:33:19 2013 From: report at bugs.python.org (=?utf-8?q?Charles-Fran=C3=A7ois_Natali?=) Date: Mon, 05 Aug 2013 05:33:19 +0000 Subject: [issue18078] threading.Condition to allow notify on a specific waiter In-Reply-To: <1375667289.1.0.153864522958.issue18078@psf.upfronthosting.co.za> Message-ID: Charles-Fran?ois Natali added the comment: > FWIW, I don't support adding this functionality. I don't see precedents for > Condition Variables behaving this way in other languages. Also, I don't > think it is worth the added complexity, learning curve, and maintenance > burden. Condition variables are used as primitive for other mutexes and I > think we ought to keep them somewhat simple. > > If someone wants to notify a specific waiter, then they have other options > such as using a separate condition variable that shares the same underlying > lock (much as the code in the queue module does). That approach is easy to > reason about. That's exactly what the point I was trying to make, but Raymond sums it really nicely :-) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 08:17:49 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Mon, 05 Aug 2013 06:17:49 +0000 Subject: [issue18658] Mercurial CPython log ticket link is broken In-Reply-To: <1375667304.35.0.50370358918.issue18658@psf.upfronthosting.co.za> Message-ID: <1375683469.03.0.249375682567.issue18658@psf.upfronthosting.co.za> Vajrasky Kok added the comment: Okay, it looks like it has been fixed. The format has changed as well. Previously: 5 hours ago R David Murray Merge: #18657: remove duplicate entries from Misc/ACKS.default tip 5 hours ago R David Murray #18657: remove duplicate entries from Misc/ACKS.3.3 Now: 10 hours ago R David Murray Merge: #18657: remove duplicate entries from Misc/ACKS. [#18657] default 10 hours ago R David Murray #18657: remove duplicate entries from Misc/ACKS. [#18657] 3.3 Now we have separate link to ticket (inside the bracket) at the end of commit message, whereas previously it was inside the commit message. I guess we can close this ticket as fixed. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 08:23:35 2013 From: report at bugs.python.org (Petr.Salinger) Date: Mon, 05 Aug 2013 06:23:35 +0000 Subject: [issue18651] test failures on KFreeBSD In-Reply-To: <1375610825.98.0.456814475805.issue18651@psf.upfronthosting.co.za> Message-ID: <1375683815.87.0.631647656063.issue18651@psf.upfronthosting.co.za> Petr.Salinger added the comment: It is related to http://bugs.python.org/issue12958 http://bugs.python.org/issue17684 The second one changed support.anticipate_failure to unittest.skipIf ---------- nosy: +Petr.Salinger _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 08:54:54 2013 From: report at bugs.python.org (Roundup Robot) Date: Mon, 05 Aug 2013 06:54:54 +0000 Subject: [issue18532] hashlib.HASH objects should officially expose the hash name In-Reply-To: <1374524940.42.0.582552143445.issue18532@psf.upfronthosting.co.za> Message-ID: <3c7qV55tLCz7Llw@mail.python.org> Roundup Robot added the comment: New changeset 238c37e4c395 by Jason R. Coombs in branch 'default': Issue 18532: Added tests and documentation to formally specify the .name attribute on hashlib objects. http://hg.python.org/cpython/rev/238c37e4c395 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 08:56:07 2013 From: report at bugs.python.org (Jason R. Coombs) Date: Mon, 05 Aug 2013 06:56:07 +0000 Subject: [issue18532] hashlib.HASH objects should officially expose the hash name In-Reply-To: <1374524940.42.0.582552143445.issue18532@psf.upfronthosting.co.za> Message-ID: <1375685767.71.0.895129166301.issue18532@psf.upfronthosting.co.za> Jason R. Coombs added the comment: I've confirmed the tests pass and the updated documentation renders nicely and without warnings. These changes now make the name attribute officially-supported and tested. ---------- resolution: -> fixed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 09:23:38 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Mon, 05 Aug 2013 07:23:38 +0000 Subject: [issue18658] Mercurial CPython log ticket link is broken In-Reply-To: <1375667304.35.0.50370358918.issue18658@psf.upfronthosting.co.za> Message-ID: <1375687418.28.0.300305978279.issue18658@psf.upfronthosting.co.za> Vajrasky Kok added the comment: Wait, something weird is happening in CPython commits log website, http://hg.python.org/cpython . These are the latest four commits. age author description 45 hours ago Jason R. Coombs Issue 18532: Added tests and documentation to formally specify the .name attribute on hashlib objects.default tip 105 minutes ago Raymond Hettinger Silence compiler warning for unused declaration.2.7 11 hours ago R David Murray Merge: #18657: remove duplicate entries from Misc/ACKS. [#18657] 11 hours ago R David Murray #18657: remove duplicate entries from Misc/ACKS. [#18657]3.3 The "age" column is screwed up. 11 hours ago goes to 105 minutes ago then goes back to 45 hours ago. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 09:30:25 2013 From: report at bugs.python.org (Ezio Melotti) Date: Mon, 05 Aug 2013 07:30:25 +0000 Subject: [issue18658] Mercurial CPython log ticket link is broken In-Reply-To: <1375667304.35.0.50370358918.issue18658@psf.upfronthosting.co.za> Message-ID: <1375687825.98.0.485006792172.issue18658@psf.upfronthosting.co.za> Ezio Melotti added the comment: This is a separate issue though, isn't it? Have you tried to ctrl+f5 the page? (Also this is probably something that should be reported to the Mercurial bug tracker, since -- unlike the issue links -- is not something we modified.) ---------- nosy: +ezio.melotti _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 09:34:21 2013 From: report at bugs.python.org (timm) Date: Mon, 05 Aug 2013 07:34:21 +0000 Subject: [issue6057] sqlite3 error classes should be documented In-Reply-To: <1242673346.43.0.948670169284.issue6057@psf.upfronthosting.co.za> Message-ID: <1375688061.71.0.996753946862.issue6057@psf.upfronthosting.co.za> timm added the comment: I would find it useful to have the exception classes listed in the Python documentation rather than having to refer to two documents, but I don't have strong feelings on this. Given that nobody has fixed this for 4 years, should we just close the ticket? I'd be happy to do the necessary work if this is something we want changed, but I don't want to prepare a patch for a ticket that's never going to go anywhere. ---------- nosy: +timm _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 09:38:11 2013 From: report at bugs.python.org (Ned Deily) Date: Mon, 05 Aug 2013 07:38:11 +0000 Subject: [issue18658] Mercurial CPython log ticket link is broken In-Reply-To: <1375667304.35.0.50370358918.issue18658@psf.upfronthosting.co.za> Message-ID: <1375688291.03.0.767294845436.issue18658@psf.upfronthosting.co.za> Ned Deily added the comment: While it looks unusual, the commit list is fine. It reflects what you see currently in a "hg log". What happened is that someone imported an older local change set or something similar. It's not always easy to tell from the log. ---------- resolution: -> invalid stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 10:03:10 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Mon, 05 Aug 2013 08:03:10 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable Message-ID: <1375689790.25.0.721615428383.issue18659@psf.upfronthosting.co.za> New submission from Vajrasky Kok: There is test_precision in Lib/test_format.py which is not being unit tested. Also, there is a unused variable inside test_precision. Attached the patch to fix these problems. ---------- components: Tests files: test_precision.patch keywords: patch messages: 194459 nosy: vajrasky priority: normal severity: normal status: open title: test_precision in test_format.py is not executed and has unused variable versions: Python 3.4 Added file: http://bugs.python.org/file31162/test_precision.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 10:20:13 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Mon, 05 Aug 2013 08:20:13 +0000 Subject: [issue14323] Normalize math precision in RGB/YIQ conversion In-Reply-To: <1331831977.5.0.174772346075.issue14323@psf.upfronthosting.co.za> Message-ID: <1375690813.22.0.207825558113.issue14323@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: > Can you add a reference for the coefficients? I have only link to Wikipedia which refers to Code of Federal Regulations ?73.682. This link (http://en.wikipedia.org/wiki/YIQ) already mentioned at the top of the file. > (You claim about the current rounding is not exactly correct. While .28*g rounds .277 rather than .274, the current .52*g rounds the non-FCC .523 rather than the FCC .5251. So I avoided making the claim in the suggested entry. It is not important.) A sum of coefficients in this line should be 0 (Q=0 for R=G=B). Patch updated. I added a What's New entry and update to use of unittest.main(), rewrite rgb_to_yiq() in the form as in Wikipedia (it uses less multiplications) and write coefficients in yiq_to_rgb() with maximal precision (as calculated with Python). ---------- Added file: http://bugs.python.org/file31163/colorsys_yiq_fcc_2.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 10:47:31 2013 From: report at bugs.python.org (Louis RIVIERE) Date: Mon, 05 Aug 2013 08:47:31 +0000 Subject: [issue18660] os.read behavior on Linux Message-ID: <1375692451.71.0.0379690285011.issue18660@psf.upfronthosting.co.za> New submission from Louis RIVIERE: A call to os.read that used to work on older Linux kernel, doesn't anymore with newer Linux kernel. As a workaroud we can use libc.read (ctypes) instead of os.read. But I feel like os.read should work, as it used to. The code (and comments) can be seen here : http://code.activestate.com/recipes/576375-low-level-inotify-wrapper/ ---------- components: IO messages: 194461 nosy: dugres priority: normal severity: normal status: open title: os.read behavior on Linux type: behavior versions: Python 2.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 11:24:53 2013 From: report at bugs.python.org (Mark Dickinson) Date: Mon, 05 Aug 2013 09:24:53 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable In-Reply-To: <1375689790.25.0.721615428383.issue18659@psf.upfronthosting.co.za> Message-ID: <1375694693.23.0.525123157738.issue18659@psf.upfronthosting.co.za> Mark Dickinson added the comment: Patch looks good to me. ---------- nosy: +mark.dickinson _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 11:30:41 2013 From: report at bugs.python.org (Roundup Robot) Date: Mon, 05 Aug 2013 09:30:41 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable In-Reply-To: <1375689790.25.0.721615428383.issue18659@psf.upfronthosting.co.za> Message-ID: <3c7txs0J9Sz7LjX@mail.python.org> Roundup Robot added the comment: New changeset cfd875bcbe41 by Mark Dickinson in branch 'default': Issue #18659: fix test_format test that wasn't being executed. Thanks Vajrasky Kok for the patch. http://hg.python.org/cpython/rev/cfd875bcbe41 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 11:31:45 2013 From: report at bugs.python.org (Mark Dickinson) Date: Mon, 05 Aug 2013 09:31:45 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable In-Reply-To: <1375689790.25.0.721615428383.issue18659@psf.upfronthosting.co.za> Message-ID: <1375695105.48.0.984451405696.issue18659@psf.upfronthosting.co.za> Mark Dickinson added the comment: Fixed. Thanks! ---------- assignee: -> mark.dickinson resolution: -> fixed stage: -> committed/rejected status: open -> closed type: -> behavior _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 11:43:08 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Mon, 05 Aug 2013 09:43:08 +0000 Subject: [issue18661] Typo in grpmodule.c Message-ID: <1375695788.15.0.911930238621.issue18661@psf.upfronthosting.co.za> New submission from Vajrasky Kok: I guess, there is a typo in Modules/grpmodule.c. See the patch below: diff -r f4f81ebc3de9 Modules/grpmodule.c --- a/Modules/grpmodule.c Sun Aug 04 15:50:08 2013 -0400 +++ b/Modules/grpmodule.c Mon Aug 05 17:40:33 2013 +0800 @@ -10,7 +10,7 @@ {"gr_name", "group name"}, {"gr_passwd", "password"}, {"gr_gid", "group id"}, - {"gr_mem", "group memebers"}, + {"gr_mem", "group members"}, {0} }; I am not sure whether the line after typo should be {0} or {0, 0}. ---------- assignee: docs at python components: Documentation messages: 194465 nosy: docs at python, vajrasky priority: normal severity: normal status: open title: Typo in grpmodule.c versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 11:53:44 2013 From: report at bugs.python.org (Mark Dickinson) Date: Mon, 05 Aug 2013 09:53:44 +0000 Subject: [issue18661] Typo in grpmodule.c In-Reply-To: <1375695788.15.0.911930238621.issue18661@psf.upfronthosting.co.za> Message-ID: <1375696424.79.0.109270162138.issue18661@psf.upfronthosting.co.za> Mark Dickinson added the comment: {0} is fine; some compilers will warn about it, but I believe it's valid C. ---------- nosy: +mark.dickinson _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 11:57:37 2013 From: report at bugs.python.org (Mark Dickinson) Date: Mon, 05 Aug 2013 09:57:37 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable In-Reply-To: <1375689790.25.0.721615428383.issue18659@psf.upfronthosting.co.za> Message-ID: <1375696657.92.0.320978076187.issue18659@psf.upfronthosting.co.za> Mark Dickinson added the comment: Okay, that caused some buildbots to fail. I'm going to back out the change until I have time to figure out what's going on. ---------- resolution: fixed -> status: closed -> open _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 12:00:08 2013 From: report at bugs.python.org (Roundup Robot) Date: Mon, 05 Aug 2013 10:00:08 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable In-Reply-To: <1375689790.25.0.721615428383.issue18659@psf.upfronthosting.co.za> Message-ID: <3c7vbq65mmz7LkW@mail.python.org> Roundup Robot added the comment: New changeset 9bee1fd64ee6 by Mark Dickinson in branch 'default': Issue #18659: Backed out changeset cfd875bcbe41 after buildbot failures. http://hg.python.org/cpython/rev/9bee1fd64ee6 ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 12:01:42 2013 From: report at bugs.python.org (Mark Dickinson) Date: Mon, 05 Aug 2013 10:01:42 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable In-Reply-To: <1375689790.25.0.721615428383.issue18659@psf.upfronthosting.co.za> Message-ID: <1375696902.83.0.675838327294.issue18659@psf.upfronthosting.co.za> Mark Dickinson added the comment: Sample buildbot output here: http://buildbot.python.org/all/builders/x86%20RHEL%206%203.x/builds/2485/steps/test/logs/stdio Relevant snippet: test_precision (test.test_format.FormatTest) ... FAIL ====================================================================== FAIL: test_precision (test.test_format.FormatTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/buildbot/buildarea/3.x.coghlan-redhat/build/Lib/test/test_format.py", line 338, in test_precision self.assertEqual(str(cm.exception), "precision too big") AssertionError: 'Too many decimal digits in format string' != 'precision too big' - Too many decimal digits in format string + precision too big ---------------------------------------------------------------------- Ran 5 tests in 0.011s ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 12:35:01 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Mon, 05 Aug 2013 10:35:01 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable In-Reply-To: <1375689790.25.0.721615428383.issue18659@psf.upfronthosting.co.za> Message-ID: <1375698901.01.0.0631110144547.issue18659@psf.upfronthosting.co.za> Vajrasky Kok added the comment: Let me help you to debug this issue. ethan at amiau:~/Documents/code/python/cpython$ cat /tmp/a.py import sys INT_MAX = sys.maxsize f = 1.2 format(f, ".%sf" % (INT_MAX + 1)) ethan at amiau:~/Documents/code/python/cpython$ ./python /tmp/a.py Traceback (most recent call last): File "/tmp/a.py", line 5, in format(f, ".%sf" % (INT_MAX + 1)) ValueError: Too many decimal digits in format string ethan at amiau:~/Documents/code/python/cpython$ cat /tmp/b.py import sys INT_MAX = 2147483647 f = 1.2 format(f, ".%sf" % (INT_MAX + 1)) ethan at amiau:~/Documents/code/python/cpython$ ./python /tmp/b.py Traceback (most recent call last): File "/tmp/b.py", line 5, in format(f, ".%sf" % (INT_MAX + 1)) ValueError: precision too big My question is whether we should have different exception message for these two cases? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 12:47:12 2013 From: report at bugs.python.org (Ronald Oussoren) Date: Mon, 05 Aug 2013 10:47:12 +0000 Subject: [issue18660] os.read behavior on Linux In-Reply-To: <1375692451.71.0.0379690285011.issue18660@psf.upfronthosting.co.za> Message-ID: <1375699632.55.0.249259847364.issue18660@psf.upfronthosting.co.za> Changes by Ronald Oussoren : ---------- nosy: +ronaldoussoren _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 12:48:30 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Mon, 05 Aug 2013 10:48:30 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable In-Reply-To: <1375689790.25.0.721615428383.issue18659@psf.upfronthosting.co.za> Message-ID: <1375699710.11.0.122592826925.issue18659@psf.upfronthosting.co.za> Vajrasky Kok added the comment: For now, instead of hardcoding INT_MAX to 2147483647 in test, maybe we can use module: >>> import IN >>> IN.INT_MAX 2147483647 ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 14:34:48 2013 From: report at bugs.python.org (Mark Dickinson) Date: Mon, 05 Aug 2013 12:34:48 +0000 Subject: [issue18652] Add itertools.first_true (return first true item in iterable) In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375706088.12.0.829778700774.issue18652@psf.upfronthosting.co.za> Mark Dickinson added the comment: +1 on the name 'first_true'. Does exactly what it says on the tin. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 14:48:39 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Mon, 05 Aug 2013 12:48:39 +0000 Subject: [issue18515] zipfile._ZipDecryptor generates wasteful crc32 table on import In-Reply-To: <1374331044.49.0.0628884037506.issue18515@psf.upfronthosting.co.za> Message-ID: <1375706919.75.0.0292921714135.issue18515@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: The objection to zipfile-no-crc32.patch is that binascii.crc32() and _crc32() have different signatures. binascii.crc32() accepts a byte object while _crc32() accepts a single integer. With packing this value into a bytes object _crc32() will be much slower. As for zdlazy.patch, there is a proposed patch in issue10030 which speedups pure Python decryption. I'm afraid that with zdlazy.patch this path will lose a part of it's speedup. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 14:48:58 2013 From: report at bugs.python.org (Hynek Schlawack) Date: Mon, 05 Aug 2013 12:48:58 +0000 Subject: [issue18652] Add itertools.first_true (return first true item in iterable) In-Reply-To: <1375706088.12.0.829778700774.issue18652@psf.upfronthosting.co.za> Message-ID: Hynek Schlawack added the comment: > +1 on the name 'first_true'. Does exactly what it says on the tin. I fully agree. *** I assume what's missing now is a permission from Raymond to mess with his turf? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 14:54:43 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Mon, 05 Aug 2013 12:54:43 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable In-Reply-To: <1375689790.25.0.721615428383.issue18659@psf.upfronthosting.co.za> Message-ID: <1375707283.61.0.15197806606.issue18659@psf.upfronthosting.co.za> Changes by Serhiy Storchaka : ---------- nosy: +haypo, serhiy.storchaka _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 15:08:04 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Mon, 05 Aug 2013 13:08:04 +0000 Subject: [issue13083] _sre: getstring() releases the buffer before using it In-Reply-To: <1317433851.47.0.137164360321.issue13083@psf.upfronthosting.co.za> Message-ID: <1375708084.73.0.696421650655.issue13083@psf.upfronthosting.co.za> Changes by Serhiy Storchaka : ---------- resolution: -> duplicate stage: -> committed/rejected status: open -> closed superseder: -> Segfault when using re.finditer over mmap _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 15:08:38 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Mon, 05 Aug 2013 13:08:38 +0000 Subject: [issue13083] _sre: getstring() releases the buffer before using it In-Reply-To: <1317433851.47.0.137164360321.issue13083@psf.upfronthosting.co.za> Message-ID: <1375708118.55.0.134127289846.issue13083@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: Agree. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 15:12:19 2013 From: report at bugs.python.org (STINNER Victor) Date: Mon, 05 Aug 2013 13:12:19 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable In-Reply-To: <1375689790.25.0.721615428383.issue18659@psf.upfronthosting.co.za> Message-ID: <1375708339.01.0.852459609936.issue18659@psf.upfronthosting.co.za> STINNER Victor added the comment: The IN module must not be used, it is hardcoded and never regenerated. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 15:16:03 2013 From: report at bugs.python.org (STINNER Victor) Date: Mon, 05 Aug 2013 13:16:03 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable In-Reply-To: <1375689790.25.0.721615428383.issue18659@psf.upfronthosting.co.za> Message-ID: <1375708563.75.0.0112694018516.issue18659@psf.upfronthosting.co.za> STINNER Victor added the comment: I added the test in the following commit: changeset: 84266:ef5175d08e7e branch: 3.3 parent: 84263:7ecca1a98220 user: Victor Stinner date: Sun Jun 23 14:54:30 2013 +0200 files: Lib/test/test_format.py Misc/NEWS Python/formatter_unicode.c description: Issue #18137: Detect integer overflow on precision in float.__format__() and complex.__format__(). ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 15:26:11 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Mon, 05 Aug 2013 13:26:11 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable In-Reply-To: <1375689790.25.0.721615428383.issue18659@psf.upfronthosting.co.za> Message-ID: <1375709171.21.0.676539356568.issue18659@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: We have _testcapi.INT_MAX. I guess different exceptions raised on 64-bit platform. First parser checks that a number can be represented as Py_ssize_t (i.e. <= PY_SSIZE_T_MAX). Here "Too many decimal digits in format string" can be raised. Then precision passed to internal function which accepts int and checked to be <= INT_MAX before cast to int. Here "precision too big" can be raised. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 15:39:29 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Mon, 05 Aug 2013 13:39:29 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable In-Reply-To: <1375689790.25.0.721615428383.issue18659@psf.upfronthosting.co.za> Message-ID: <1375709969.51.0.403840413799.issue18659@psf.upfronthosting.co.za> Vajrasky Kok added the comment: For the passers-by who want to help: The "precision too big" exception is raised in Python/formatter_unicode.c line 1168 and 1002. The "Too many decimal digits..." exception is raised in Python/formatter_unicode.c line 71. So the question is whether it is beneficial to differentiate the exception message. If not, we can change the exception message or test whether the digit passes INT_MAX first before checking with sys.max_size. If yes, we need to add test case for sys.max_size and use _testcapi.INT_MAX for current unit test case. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 16:08:50 2013 From: report at bugs.python.org (Ezio Melotti) Date: Mon, 05 Aug 2013 14:08:50 +0000 Subject: [issue18273] Simplify calling and discovery of json test package In-Reply-To: <1371760220.13.0.623339240586.issue18273@psf.upfronthosting.co.za> Message-ID: <1375711730.18.0.155931361034.issue18273@psf.upfronthosting.co.za> Ezio Melotti added the comment: I like the patch. Can you make "./python Lib/test/test_json/" work too? Currently it doesn't seem to work (it works for e.g. "./python Lib/test/test_email/"). ---------- stage: -> patch review _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 16:15:46 2013 From: report at bugs.python.org (Ezio Melotti) Date: Mon, 05 Aug 2013 14:15:46 +0000 Subject: [issue14323] Normalize math precision in RGB/YIQ conversion In-Reply-To: <1331831977.5.0.174772346075.issue14323@psf.upfronthosting.co.za> Message-ID: <1375712146.64.0.429621913718.issue14323@psf.upfronthosting.co.za> Ezio Melotti added the comment: LGTM. ---------- stage: patch review -> commit review _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 16:35:25 2013 From: report at bugs.python.org (=?utf-8?q?Jo=C3=A3o_Bernardo?=) Date: Mon, 05 Aug 2013 14:35:25 +0000 Subject: [issue18078] threading.Condition to allow notify on a specific waiter In-Reply-To: <1369712419.12.0.434704480843.issue18078@psf.upfronthosting.co.za> Message-ID: <1375713325.96.0.990889391693.issue18078@psf.upfronthosting.co.za> Jo?o Bernardo added the comment: Seems like "just because I never used I don't support". Boost C++ libraries has a wait_for_any functionality to synchronize futures. C# has a WaitAny in the WaitHandle class (like our Condition). Another problem is: the Condition class cannot be easily subclassed because all the important bits are _protected... Can you add an interface for the "_waiters" list and "_lock" objects?? If you do that I'll be happy subclassing it. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 16:41:28 2013 From: report at bugs.python.org (Ezio Melotti) Date: Mon, 05 Aug 2013 14:41:28 +0000 Subject: [issue18585] Add a text truncation function In-Reply-To: <1375102150.65.0.445691594018.issue18585@psf.upfronthosting.co.za> Message-ID: <1375713688.23.0.444982090114.issue18585@psf.upfronthosting.co.za> Ezio Melotti added the comment: [...] and ASCII are fine with me. > Perhaps there could be an argument controlling where to truncate > (left, right or centre). A good use-case for the new Enums, perhaps? :-) I wrote a similar function once and in addition to the width it had this feature too (defaulting on "center"), so it sounds like a reasonable addition to me. Back then I was simply passing a "left"/"right"/"center" string -- not sure it's worth adding an enum for this (FWIW for text alignment there are 3 separate methods: ljust, center, and rjust). ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 16:48:10 2013 From: report at bugs.python.org (Ezio Melotti) Date: Mon, 05 Aug 2013 14:48:10 +0000 Subject: [issue18585] Add a text truncation function In-Reply-To: <1375102150.65.0.445691594018.issue18585@psf.upfronthosting.co.za> Message-ID: <1375714090.12.0.361575580728.issue18585@psf.upfronthosting.co.za> Ezio Melotti added the comment: Perhaps "shorten" would be a better name -- "summarize" sounds smarter than it actually is :) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 17:14:25 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Mon, 05 Aug 2013 15:14:25 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable In-Reply-To: <1375689790.25.0.721615428383.issue18659@psf.upfronthosting.co.za> Message-ID: <1375715665.67.0.889852366718.issue18659@psf.upfronthosting.co.za> Vajrasky Kok added the comment: Okay, I guess the fix for this ticket should be kept simple. If we want to merge the exception message or touch the code base or do something smarter than fixing the test, maybe we should create a separate ticket. So I used Serhiy Storchaka's suggestion to use _testcapi.INT_MAX for the second patch. ---------- Added file: http://bugs.python.org/file31164/test_precision_v2.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 17:14:26 2013 From: report at bugs.python.org (R. David Murray) Date: Mon, 05 Aug 2013 15:14:26 +0000 Subject: [issue18585] Add a text truncation function In-Reply-To: <1375102150.65.0.445691594018.issue18585@psf.upfronthosting.co.za> Message-ID: <1375715666.8.0.768627669498.issue18585@psf.upfronthosting.co.za> R. David Murray added the comment: Looking just at the proposed functionality (taking a prefix) and ignoring the requested complexification :), the usual name for the text produced by this process is a "lead" (http://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style/Lead_section), although formally a lead is actually written to be used as such, as opposed to just taking a prefix, so that word really has the same problem as 'summarize'. I think 'truncate' would be a better name. Or, if you don't mind being wordier, extract_prefix. The fact that it is part of the textwrap module should be enough clue that the truncation happens at whitespace. Truncate could also apply to the expanded version if you squint a little, if Antoine is interested in that. On the other hand, the use case presented for that is not going to be served by this function anyway, since this function (being part of textwrap) breaks on whitespace...it shouldn't (IMO) elide text other than at whitespace. If you want that functionality it belongs in some other module, I think. The placeholder argument could alternatively be named 'ellipsis', but placeholder is certainly fine. shorten would probably be better if you are going with the expanded version, but I like truncate. It is probably significant that that is what the title of the issue calls it :) ---------- nosy: +r.david.murray _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 17:18:33 2013 From: report at bugs.python.org (Ezio Melotti) Date: Mon, 05 Aug 2013 15:18:33 +0000 Subject: [issue18472] Update PEP 8 to encourage modern conventions In-Reply-To: <1373973528.84.0.159091610788.issue18472@psf.upfronthosting.co.za> Message-ID: <1375715913.19.0.944241478055.issue18472@psf.upfronthosting.co.za> Ezio Melotti added the comment: I'm a bit late but I still have a few comments: + The paren-using form also means that when the exception arguments are + long or include string formatting, you don't need to use line + continuation characters thanks to the containing parentheses. This paragraph doesn't add much and could be removed IMHO. +- When binding caught exceptions to a name, prefer the explicit name + binding syntax added in Python 2.6:: + + try: + process_data() + except Exception as exc: + raise DataProcessingFailedError(str(exc)) It took me a bit to realize that this is talking about "as". I think it would be better to be more explicit, and simplify the example a bit so that it's not as distracting. + Note that in Python 3, ``unicode`` and ``basestring`` no longer exist + (there is only ``str``) and a bytes object is no longer a kind of + string (it is a sequence of integers instead) Is there any specific reason to use "sequence of integers" instead of "sequence of bytes"? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 17:33:47 2013 From: report at bugs.python.org (Steven D'Aprano) Date: Mon, 05 Aug 2013 15:33:47 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375500120.19.0.896650033196.issue18606@psf.upfronthosting.co.za> Message-ID: <51FFC5D3.3040606@pearwood.info> Steven D'Aprano added the comment: On 03/08/13 13:22, Alexander Belopolsky wrote: > > Alexander Belopolsky added the comment: > > The implementation of median and mode families of functions as classes is clever, So long as it is not too clever. > but I am not sure it is a good idea to return something other than an instance of the class from __new__(). Returning foreign instances is supported behaviour for __new__. (If the object returned from __new__ is not an instance, __init__ is not called.) I believe the current implementation is reasonable and prefer to keep it. If I use the traditional implementation, there will only be one instance, with no state, only methods. That's a rather poor excuse for an instance, and a class already is a singleton object with methods and (in this case) no state, so creating an instance as well adds nothing. I will change the implementation if the consensus among senior devs is against it, but would prefer not to. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 17:58:18 2013 From: report at bugs.python.org (Tim Golden) Date: Mon, 05 Aug 2013 15:58:18 +0000 Subject: [issue2528] Change os.access to check ACLs under Windows In-Reply-To: <1207059558.9.0.891835325783.issue2528@psf.upfronthosting.co.za> Message-ID: <1375718298.11.0.238308417756.issue2528@psf.upfronthosting.co.za> Tim Golden added the comment: Here's an updated patch against trunk with tests & doc changes ---------- status: languishing -> open Added file: http://bugs.python.org/file31165/issue2528.2.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 18:00:48 2013 From: report at bugs.python.org (Tim Golden) Date: Mon, 05 Aug 2013 16:00:48 +0000 Subject: [issue2528] Change os.access to check ACLs under Windows In-Reply-To: <1207059558.9.0.891835325783.issue2528@psf.upfronthosting.co.za> Message-ID: <1375718448.61.0.0235577384862.issue2528@psf.upfronthosting.co.za> Tim Golden added the comment: ... and to answer Amaury's question in msg109871 it creates a reasonable consistency between the results of os.access and the user's actual ability to read / write a file. eg, you might have no permissions whatsoever on the file but as long as it wasn't read-only, os.access would return True for reading, writing and executing. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 18:45:28 2013 From: report at bugs.python.org (Laszlo Papp) Date: Mon, 05 Aug 2013 16:45:28 +0000 Subject: [issue17372] provide pretty printer for xml.etree.ElementTree In-Reply-To: <1362640725.41.0.836381435016.issue17372@psf.upfronthosting.co.za> Message-ID: <1375721128.34.0.0120038957355.issue17372@psf.upfronthosting.co.za> Laszlo Papp added the comment: This has just made me switching away from xml.etree.ElementTree today, sadly. What a pity; it would have been all kind of cool to stick to this minimal, otherwise working parser and builder. ---------- nosy: +lpapp _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 18:46:15 2013 From: report at bugs.python.org (Mark Dickinson) Date: Mon, 05 Aug 2013 16:46:15 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375258820.22.0.0684222529612.issue18606@psf.upfronthosting.co.za> Message-ID: <1375721175.57.0.955691615644.issue18606@psf.upfronthosting.co.za> Changes by Mark Dickinson : ---------- nosy: +mark.dickinson _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 18:58:15 2013 From: report at bugs.python.org (Roundup Robot) Date: Mon, 05 Aug 2013 16:58:15 +0000 Subject: [issue18661] Typo in grpmodule.c In-Reply-To: <1375695788.15.0.911930238621.issue18661@psf.upfronthosting.co.za> Message-ID: <3c84tG4696z7Ln0@mail.python.org> Roundup Robot added the comment: New changeset 395ac61ebe1a by Mark Dickinson in branch '2.7': Issue #18661: typo in grp.struct_group docstring. http://hg.python.org/cpython/rev/395ac61ebe1a New changeset 791034a0ae1e by Mark Dickinson in branch '3.3': Issue #18661: typo in grp.struct_group docstring. Thanks Vajrasky Kok. http://hg.python.org/cpython/rev/791034a0ae1e New changeset f534960c2c02 by Mark Dickinson in branch 'default': Issue #18661: typo in grp.struct_group docstring (fix merged from 3.3). Thanks Vajrasky Kok. http://hg.python.org/cpython/rev/f534960c2c02 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 18:59:03 2013 From: report at bugs.python.org (Mark Dickinson) Date: Mon, 05 Aug 2013 16:59:03 +0000 Subject: [issue18661] Typo in grpmodule.c In-Reply-To: <1375695788.15.0.911930238621.issue18661@psf.upfronthosting.co.za> Message-ID: <1375721943.7.0.0258047565807.issue18661@psf.upfronthosting.co.za> Mark Dickinson added the comment: Fixed. Thanks for the report! ---------- resolution: -> fixed stage: -> committed/rejected status: open -> closed type: -> behavior versions: +Python 2.7, Python 3.3 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 19:08:22 2013 From: report at bugs.python.org (Mark Dickinson) Date: Mon, 05 Aug 2013 17:08:22 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375258820.22.0.0684222529612.issue18606@psf.upfronthosting.co.za> Message-ID: <1375722502.04.0.658900088022.issue18606@psf.upfronthosting.co.za> Mark Dickinson added the comment: I too find the use of a class that'll never be instantiated peculiar. As you say, there's no state to be stored. So why not simply have separate functions `median`, `median_low`, `median_high`, `median_grouped`, etc.? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 19:10:44 2013 From: report at bugs.python.org (James Laver) Date: Mon, 05 Aug 2013 17:10:44 +0000 Subject: [issue18662] re.escape should not escape the hyphen Message-ID: <1375722644.22.0.61356481393.issue18662@psf.upfronthosting.co.za> New submission from James Laver: Traceback (most recent call last): File "/Users/jlaver/retest.py", line 6, in test_escape self.assertEquals(re.escape('-'), '-') AssertionError: '\\-' != '-' The only place you can do bad things with hyphens is in a character class. I fail to see how you'd be in the situation of wanting to use escape()d data in a character class. Even if I could think of a reason to do that, it's decidedly not the usual case. It's http://bugs.python.org/issue2650 all over again, just with a different character (in that case, underscore). While we're at it, what else shouldn't it be escaping? ---------- components: Regular Expressions files: rebugtest.py messages: 194495 nosy: ezio.melotti, jjl, mrabarnett priority: normal severity: normal status: open title: re.escape should not escape the hyphen type: behavior versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5 Added file: http://bugs.python.org/file31166/rebugtest.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 19:19:34 2013 From: report at bugs.python.org (Matthew Barnett) Date: Mon, 05 Aug 2013 17:19:34 +0000 Subject: [issue18662] re.escape should not escape the hyphen In-Reply-To: <1375722644.22.0.61356481393.issue18662@psf.upfronthosting.co.za> Message-ID: <1375723174.54.0.996659282242.issue18662@psf.upfronthosting.co.za> Matthew Barnett added the comment: The help says: """>>> help(re.escape) Help on function escape in module re: escape(pattern) Escape all the characters in pattern except ASCII letters, numbers and '_'. """ The complementary approach is to escape _only_ the metacharacters. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 19:35:44 2013 From: report at bugs.python.org (James Laver) Date: Mon, 05 Aug 2013 17:35:44 +0000 Subject: [issue18662] re.escape should not escape the hyphen In-Reply-To: <1375722644.22.0.61356481393.issue18662@psf.upfronthosting.co.za> Message-ID: <1375724144.3.0.671521534348.issue18662@psf.upfronthosting.co.za> James Laver added the comment: Quite right, it does say that in the documentation. The documentation is perfectly correct, but the behaviour is wrong in my opinion and as you suggest, we should be escaping metacharacters only. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 19:53:10 2013 From: report at bugs.python.org (py.user) Date: Mon, 05 Aug 2013 17:53:10 +0000 Subject: [issue18663] In unittest.TestCase.assertAlmostEqual doc specify the delta description Message-ID: <1375725190.79.0.442588525807.issue18663@psf.upfronthosting.co.za> New submission from py.user: http://docs.python.org/3/library/unittest.html#unittest.TestCase.assertAlmostEqual "If delta is supplied instead of places then the difference between first and second must be less (or more) than delta." ---------- assignee: docs at python components: Documentation files: issue.diff keywords: patch messages: 194498 nosy: docs at python, py.user priority: normal severity: normal status: open title: In unittest.TestCase.assertAlmostEqual doc specify the delta description type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file31167/issue.diff _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 20:14:23 2013 From: report at bugs.python.org (Steven D'Aprano) Date: Mon, 05 Aug 2013 18:14:23 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375722502.04.0.658900088022.issue18606@psf.upfronthosting.co.za> Message-ID: <51FFEB73.7060803@pearwood.info> Steven D'Aprano added the comment: On 06/08/13 03:08, Mark Dickinson wrote: > > I too find the use of a class that'll never be instantiated peculiar. I'll accept "unusual", but not "peculiar". It's an obvious extension to classes being first-class objects. We use classes as objects very frequently, we call methods on classes directly (e.g. int.fromhex). This is just a trivial variation where I am using a class-as-object as a function. But if this is really going to be a sticking point, I can avoid using a class. I'll make median a plain function. Will that be acceptable? > As you say, there's no state to be stored. So why not simply have separate functions `median`, `median_low`, `median_high`, `median_grouped`, etc.? Why have a pseudo-namespace median_* when we could have a real namespace median.* ? I discussed my reasons for this here: http://mail.python.org/pipermail/python-ideas/2013-August/022612.html ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 20:32:15 2013 From: report at bugs.python.org (Tim Golden) Date: Mon, 05 Aug 2013 18:32:15 +0000 Subject: [issue2528] Change os.access to check ACLs under Windows In-Reply-To: <1207059558.9.0.891835325783.issue2528@psf.upfronthosting.co.za> Message-ID: <1375727535.32.0.504710745574.issue2528@psf.upfronthosting.co.za> Changes by Tim Golden : Removed file: http://bugs.python.org/file9919/os_access-r62091.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 20:32:43 2013 From: report at bugs.python.org (Ned Deily) Date: Mon, 05 Aug 2013 18:32:43 +0000 Subject: [issue18273] Simplify calling and discovery of json test package In-Reply-To: <1371760220.13.0.623339240586.issue18273@psf.upfronthosting.co.za> Message-ID: <1375727563.84.0.52546609279.issue18273@psf.upfronthosting.co.za> Ned Deily added the comment: Make sure the tests still work when run from an installed Python rather than just from a build directory. In particular, if you rename test directories, you will need to change LIBSUBDIRS in Makefile.pre.in to ensure the directories and their files are installed. ---------- nosy: +ned.deily _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 20:36:11 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Mon, 05 Aug 2013 18:36:11 +0000 Subject: [issue18585] Add a text truncation function In-Reply-To: <1375715666.8.0.768627669498.issue18585@psf.upfronthosting.co.za> Message-ID: <1375727763.2557.3.camel@fsol> Antoine Pitrou added the comment: > Looking just at the proposed functionality (taking a prefix) and > ignoring the requested complexification :), the usual name for the > text produced by this process is a > "lead" (http://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style/Lead_section), although formally a lead is actually written to be used as such, as opposed to just taking a prefix, so that word really has the same problem as 'summarize'. Good point. > The placeholder argument could alternatively be named 'ellipsis', but > placeholder is certainly fine. I would certainly like ellipsis if it didn't already mean something else in Python. > shorten would probably be better if you are going with the expanded > version, but I like truncate. It is probably significant that that is > what the title of the issue calls it :) I'm a bit negative towards truncate(), mostly because I've worked on the I/O stack and truncate means something much less careful there (e.g. StringIO.truncate()). But really, I'm fine with either shorten() or truncate(). I agree summarize() may try to look a bit too smart. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 20:38:31 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Mon, 05 Aug 2013 18:38:31 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <51FFEB73.7060803@pearwood.info> Message-ID: Alexander Belopolsky added the comment: On Mon, Aug 5, 2013 at 2:14 PM, Steven D'Aprano wrote: > > As you say, there's no state to be stored. So why not simply have > separate functions `median`, `median_low`, `median_high`, `median_grouped`, > etc.? > > Why have a pseudo-namespace median_* when we could have a real namespace > median.* ? I am with Steven on this one. Note that these functions are expected to be used interactively and with standard US keyboards "." is much easier to type than "_". My only objection is to having a class xyz such that isinstance(xyz(..), xyz) is false. While this works with CPython, it may present problems for other implementations. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 20:57:19 2013 From: report at bugs.python.org (Mark Dickinson) Date: Mon, 05 Aug 2013 18:57:19 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375258820.22.0.0684222529612.issue18606@psf.upfronthosting.co.za> Message-ID: <1375729039.68.0.696618611669.issue18606@psf.upfronthosting.co.za> Mark Dickinson added the comment: > My only objection is to having a class xyz such that isinstance(xyz(..), > xyz) is false. Yep. Use a set of functions (median, median_low); use an instance of a class as Alexander describes; use a single median function that takes an optional "method" parameter; create a statistics.median subpackage and put the various median functions in that. Any of those options are fairly standard, unsurprising, and could reasonably be defended. But having `median` be a class whose `__new__` returns a float really *is* nonstandard and peculiar. There's just no need for such perversity in what should be a straightforward and uncomplicated module. Special cases aren't special enough to break the rules and all that. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 21:06:59 2013 From: report at bugs.python.org (Terry J. Reedy) Date: Mon, 05 Aug 2013 19:06:59 +0000 Subject: [issue14323] Normalize math precision in RGB/YIQ conversion In-Reply-To: <1331831977.5.0.174772346075.issue14323@psf.upfronthosting.co.za> Message-ID: <1375729619.87.0.199642545593.issue14323@psf.upfronthosting.co.za> Terry J. Reedy added the comment: I agree. Go ahead and push. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 21:16:30 2013 From: report at bugs.python.org (Terry J. Reedy) Date: Mon, 05 Aug 2013 19:16:30 +0000 Subject: [issue18472] Update PEP 8 to encourage modern conventions In-Reply-To: <1373973528.84.0.159091610788.issue18472@psf.upfronthosting.co.za> Message-ID: <1375730190.11.0.321366321552.issue18472@psf.upfronthosting.co.za> Terry J. Reedy added the comment: Ezio 2. Explicitly say "use 'as' instead of ','". Someone who does not know that 'as' is available since 2.6 may not understand. 3. 'byte' may be interpreted as 'char', especially for someone using 2.x 'bytes'. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 21:31:51 2013 From: report at bugs.python.org (R. David Murray) Date: Mon, 05 Aug 2013 19:31:51 +0000 Subject: [issue18472] Update PEP 8 to encourage modern conventions In-Reply-To: <1373973528.84.0.159091610788.issue18472@psf.upfronthosting.co.za> Message-ID: <1375731111.94.0.13886705282.issue18472@psf.upfronthosting.co.za> R. David Murray added the comment: Technically a bytes object is sequence of integers, not a sequence of bytes. That is, if you iterate it, you get integers. Python doesn't have a 'byte' type. ---------- nosy: +r.david.murray _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 21:38:32 2013 From: report at bugs.python.org (Mark Dickinson) Date: Mon, 05 Aug 2013 19:38:32 +0000 Subject: [issue14323] Normalize math precision in RGB/YIQ conversion In-Reply-To: <1331831977.5.0.174772346075.issue14323@psf.upfronthosting.co.za> Message-ID: <1375731512.46.0.95921102228.issue14323@psf.upfronthosting.co.za> Mark Dickinson added the comment: LGTM too. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 22:35:18 2013 From: report at bugs.python.org (Raymond Hettinger) Date: Mon, 05 Aug 2013 20:35:18 +0000 Subject: [issue18078] threading.Condition to allow notify on a specific waiter In-Reply-To: <1369712419.12.0.434704480843.issue18078@psf.upfronthosting.co.za> Message-ID: <1375734918.43.0.0307586038397.issue18078@psf.upfronthosting.co.za> Changes by Raymond Hettinger : ---------- assignee: -> rhettinger _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 23:14:48 2013 From: report at bugs.python.org (Alex Henderson) Date: Mon, 05 Aug 2013 21:14:48 +0000 Subject: [issue14465] xml.etree.ElementTree: add feature to prettify XML output In-Reply-To: <1333294084.01.0.984287406664.issue14465@psf.upfronthosting.co.za> Message-ID: <1375737288.43.0.101654913398.issue14465@psf.upfronthosting.co.za> Alex Henderson added the comment: Proposed patch copied over from duplicate issue 17372. ---------- keywords: +patch nosy: +alex.henderson Added file: http://bugs.python.org/file31168/issue14465.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 23:17:43 2013 From: report at bugs.python.org (Roundup Robot) Date: Mon, 05 Aug 2013 21:17:43 +0000 Subject: [issue4885] mmap enhancement request In-Reply-To: <1231445893.72.0.162990779773.issue4885@psf.upfronthosting.co.za> Message-ID: <3c8Bdf2yJnzSdn@mail.python.org> Roundup Robot added the comment: New changeset 1754b7900da1 by Antoine Pitrou in branch 'default': Issue #4885: Add weakref support to mmap objects. Patch by Valerie Lambert. http://hg.python.org/cpython/rev/1754b7900da1 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 23:18:13 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Mon, 05 Aug 2013 21:18:13 +0000 Subject: [issue4885] mmap enhancement request In-Reply-To: <1231445893.72.0.162990779773.issue4885@psf.upfronthosting.co.za> Message-ID: <1375737493.68.0.696634225176.issue4885@psf.upfronthosting.co.za> Antoine Pitrou added the comment: Your patch is now committed. Thanks for contributing! ---------- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 23:28:01 2013 From: report at bugs.python.org (Roundup Robot) Date: Mon, 05 Aug 2013 21:28:01 +0000 Subject: [issue17934] Add a frame method to clear expensive details In-Reply-To: <1368014042.2.0.41504275061.issue17934@psf.upfronthosting.co.za> Message-ID: <3c8BsX35Y6zS7H@mail.python.org> Roundup Robot added the comment: New changeset 862ab99ab570 by Antoine Pitrou in branch 'default': Issue #17934: Add a clear() method to frame objects, to help clean up expensive details (local variables) and break reference cycles. http://hg.python.org/cpython/rev/862ab99ab570 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 23:32:19 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Mon, 05 Aug 2013 21:32:19 +0000 Subject: [issue17934] Add a frame method to clear expensive details In-Reply-To: <1368014042.2.0.41504275061.issue17934@psf.upfronthosting.co.za> Message-ID: <1375738339.19.0.279434236613.issue17934@psf.upfronthosting.co.za> Antoine Pitrou added the comment: Ok, I committed the RuntimeError-raising version. ---------- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 23:33:42 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Mon, 05 Aug 2013 21:33:42 +0000 Subject: [issue1565525] tracebacks eat up memory by holding references to locals and globals when they are not wanted Message-ID: <1375738422.95.0.000120505419772.issue1565525@psf.upfronthosting.co.za> Antoine Pitrou added the comment: frame.clear() was committed in issue17934. ---------- nosy: +pitrou _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 23:34:28 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Mon, 05 Aug 2013 21:34:28 +0000 Subject: [issue9815] assertRaises as a context manager keeps tracebacks and frames alive In-Reply-To: <1284103100.0.0.404704166803.issue9815@psf.upfronthosting.co.za> Message-ID: <1375738468.04.0.194373125054.issue9815@psf.upfronthosting.co.za> Antoine Pitrou added the comment: frame.clear() was committed in issue17934, it would allow a less brutal resolution. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 23:42:54 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Mon, 05 Aug 2013 21:42:54 +0000 Subject: [issue18652] Add itertools.first_true (return first true item in iterable) In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375738974.41.0.96965701603.issue18652@psf.upfronthosting.co.za> Antoine Pitrou added the comment: I would like to chime in and say that the fact that the functions exists in SQL (and possibly Lisp, Snobol and PHP) sells me on the idea! Okay, only joking, but I do think this is a useful addition. "first_true" should be its name, but itertools already has a tradition of nonunderscorednames, so it should be "firsttrue", which may look weird because of the doubled t. ---------- nosy: +pitrou _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Aug 5 23:47:05 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Mon, 05 Aug 2013 21:47:05 +0000 Subject: [issue18652] Add itertools.first_true (return first true item in iterable) In-Reply-To: <1375610934.97.0.503658757825.issue18652@psf.upfronthosting.co.za> Message-ID: <1375739225.42.0.422980087575.issue18652@psf.upfronthosting.co.za> Antoine Pitrou added the comment: (but you don't have to trust me: itertools also has izip_longest() and combinations_with_replacement()) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 00:19:25 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Mon, 05 Aug 2013 22:19:25 +0000 Subject: [issue18664] occasional test_threading failure Message-ID: <1375741165.75.0.0273425053979.issue18664@psf.upfronthosting.co.za> New submission from Antoine Pitrou: http://buildbot.python.org/all/builders/AMD64%20Windows%20Server%202008%20%5BSB%5D%203.x/builds/1021 ====================================================================== FAIL: test_finalize_with_trace (test.test_threading.ThreadTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "E:\home\cpython\buildslave\x64\3.x.snakebite-win2k8r2sp1-amd64\build\lib\test\test_threading.py", line 323, in test_finalize_with_trace """) File "E:\home\cpython\buildslave\x64\3.x.snakebite-win2k8r2sp1-amd64\build\lib\test\script_helper.py", line 54, in assert_python_ok return _assert_python(True, *args, **env_vars) File "E:\home\cpython\buildslave\x64\3.x.snakebite-win2k8r2sp1-amd64\build\lib\test\script_helper.py", line 46, in _assert_python "stderr follows:\n%s" % (rc, err.decode('ascii', 'ignore'))) AssertionError: Process return code is 3, stderr follows: Assertion failed: !PyErr_Occurred(), file ..\Objects\object.c, line 451 Fatal Python error: Aborted Thread 0x00000e14: File "", line 8 in killer File "E:\home\cpython\buildslave\x64\3.x.snakebite-win2k8r2sp1-amd64\build\lib\threading.py", line 599 in run File "E:\home\cpython\buildslave\x64\3.x.snakebite-win2k8r2sp1-amd64\build\lib\threading.py", line 642 in _bootstrap_inner File "E:\home\cpython\buildslave\x64\3.x.snakebite-win2k8r2sp1-amd64\build\lib\threading.py", line 619 in _bootstrap Current thread 0x000006c4: ---------- components: Interpreter Core, Tests messages: 194517 nosy: haypo, pitrou priority: normal severity: normal status: open title: occasional test_threading failure type: crash versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 00:59:51 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Mon, 05 Aug 2013 22:59:51 +0000 Subject: [issue18579] Dereference after NULL check in listobject.c merge_hi() In-Reply-To: <1375017605.96.0.0484069196925.issue18579@psf.upfronthosting.co.za> Message-ID: <1375743591.37.0.259196624197.issue18579@psf.upfronthosting.co.za> Alexander Belopolsky added the comment: According to this comment, ssb.values can be null: /* A sortslice contains a pointer to an array of keys and a pointer to * an array of corresponding values. In other words, keys[i] * corresponds with values[i]. If values == NULL, then the keys are * also the values. * * Several convenience routines are provided here, so that keys and * values are always moved in sync. */ However, is ssb.values is null, dest.values must be null as well and sortslice_copy_decr() will not dereference either of the pointers. Looks like a false positive to me, but I wonder if a strategically placed assert will silence coverity: Py_LOCAL_INLINE(void) sortslice_copy_decr(sortslice *dst, sortslice *src) { *dst->keys-- = *src->keys--; if (dst->values != NULL) { assert(src->values != NULL); *dst->values-- = *src->values--; } } ---------- nosy: +belopolsky _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 02:32:11 2013 From: report at bugs.python.org (STINNER Victor) Date: Tue, 06 Aug 2013 00:32:11 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable In-Reply-To: <1375715665.67.0.889852366718.issue18659@psf.upfronthosting.co.za> Message-ID: STINNER Victor added the comment: I realized that the new tests checking that precision larger with INT_MAX fail should be marked as specific to CPython. The import of _testcapi should be moved to a CPython specific test. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 02:36:27 2013 From: report at bugs.python.org (STINNER Victor) Date: Tue, 06 Aug 2013 00:36:27 +0000 Subject: [issue1565525] tracebacks eat up memory by holding references to locals and globals when they are not wanted Message-ID: <1375749387.1.0.837451280377.issue1565525@psf.upfronthosting.co.za> STINNER Victor added the comment: > frame.clear() was committed in issue17934. How should it be used to workaround this issue ("tracebacks eat up memory by holding references to locals and globals when they are not wanted")? We need maybe an helper to clear all frames referenced by a traceback? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 02:43:28 2013 From: report at bugs.python.org (STINNER Victor) Date: Tue, 06 Aug 2013 00:43:28 +0000 Subject: [issue18664] occasional test_threading failure In-Reply-To: <1375741165.75.0.0273425053979.issue18664@psf.upfronthosting.co.za> Message-ID: <1375749808.68.0.147112522186.issue18664@psf.upfronthosting.co.za> STINNER Victor added the comment: > Assertion failed: !PyErr_Occurred(), file ..\Objects\object.c, line 451 This error means that PyObject_Repr() was called with an exception set. It would help to know which function called PyObject_Repr() and when. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 02:44:01 2013 From: report at bugs.python.org (STINNER Victor) Date: Tue, 06 Aug 2013 00:44:01 +0000 Subject: [issue18664] occasional test_threading failure In-Reply-To: <1375741165.75.0.0273425053979.issue18664@psf.upfronthosting.co.za> Message-ID: <1375749841.96.0.266230145129.issue18664@psf.upfronthosting.co.za> Changes by STINNER Victor : ---------- nosy: +christian.heimes, serhiy.storchaka _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 05:06:43 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Tue, 06 Aug 2013 03:06:43 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable In-Reply-To: <1375689790.25.0.721615428383.issue18659@psf.upfronthosting.co.za> Message-ID: <1375758403.33.0.403365347603.issue18659@psf.upfronthosting.co.za> Vajrasky Kok added the comment: Attached the third patch. The importing _testcapi part was moved inside the test. Added cpython support only decorator for this test. ---------- Added file: http://bugs.python.org/file31169/test_precision_v3.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 06:53:20 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Tue, 06 Aug 2013 04:53:20 +0000 Subject: [issue18665] Typos in frame object related code Message-ID: <1375764800.58.0.482122024787.issue18665@psf.upfronthosting.co.za> New submission from Vajrasky Kok: See the patch for details: diff -r 438cdc97d8ee Include/frameobject.h --- a/Include/frameobject.h Mon Aug 05 23:35:43 2013 +0200 +++ b/Include/frameobject.h Tue Aug 06 12:38:15 2013 +0800 @@ -36,7 +36,7 @@ non-generator frames. See the save_exc_state and swap_exc_state functions in ceval.c for details of their use. */ PyObject *f_exc_type, *f_exc_value, *f_exc_traceback; - /* Borrowed referenced to a generator, or NULL */ + /* Borrowed reference to a generator, or NULL */ PyObject *f_gen; PyThreadState *f_tstate; diff -r 438cdc97d8ee Lib/test/test_frame.py --- a/Lib/test/test_frame.py Mon Aug 05 23:35:43 2013 +0200 +++ b/Lib/test/test_frame.py Tue Aug 06 12:38:15 2013 +0800 @@ -93,7 +93,7 @@ @support.cpython_only def test_clear_refcycles(self): - # .clear() doesn't leave any refcycle behin + # .clear() doesn't leave any refcycle behind. with support.disable_gc(): class C: pass About the second comment, I am not sure to put dot or not. In that file, I saw some comments use dot, others don't. ---------- assignee: docs at python components: Documentation messages: 194523 nosy: docs at python, pitrou, vajrasky priority: normal severity: normal status: open title: Typos in frame object related code versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 07:01:37 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Tue, 06 Aug 2013 05:01:37 +0000 Subject: [issue18666] Unused variable in test_frame.py Message-ID: <1375765297.44.0.682936392521.issue18666@psf.upfronthosting.co.za> New submission from Vajrasky Kok: There is a unused variable in Lib/test/test_frame.py. def test_clear_executing_generator(self): # Attempting to clear an executing generator frame is forbidden. endly = False def g(): nonlocal endly try: 1/0 except ZeroDivisionError as e: f = e.__traceback__.tb_frame with self.assertRaises(RuntimeError): f.clear() with self.assertRaises(RuntimeError): f.f_back.clear() yield f finally: endly = True gen = g() f = next(gen) self.assertFalse(endly) The variable f is hanging without any purpose. Attached the patch to give purpose to variable f. ---------- components: Tests files: test_frame.patch keywords: patch messages: 194524 nosy: pitrou, vajrasky priority: normal severity: normal status: open title: Unused variable in test_frame.py versions: Python 3.4 Added file: http://bugs.python.org/file31170/test_frame.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 07:13:02 2013 From: report at bugs.python.org (Ezio Melotti) Date: Tue, 06 Aug 2013 05:13:02 +0000 Subject: [issue18665] Typos in frame object related code In-Reply-To: <1375764800.58.0.482122024787.issue18665@psf.upfronthosting.co.za> Message-ID: <1375765982.05.0.823040455989.issue18665@psf.upfronthosting.co.za> Ezio Melotti added the comment: Can you attach the patch to the issue? Full stops for one-sentence comments can be omitted. ---------- nosy: +ezio.melotti stage: -> needs patch type: -> enhancement versions: +Python 2.7, Python 3.3 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 07:52:36 2013 From: report at bugs.python.org (Ezio Melotti) Date: Tue, 06 Aug 2013 05:52:36 +0000 Subject: [issue18662] re.escape should not escape the hyphen In-Reply-To: <1375722644.22.0.61356481393.issue18662@psf.upfronthosting.co.za> Message-ID: <1375768356.67.0.159525524396.issue18662@psf.upfronthosting.co.za> Ezio Melotti added the comment: In #2650 re.escape() was updated to match Perl's behavior. I don't think there's any actual reason to change it -- it brings no benefits and it might break some code (even if admittedly it's not very likely). ---------- type: behavior -> enhancement versions: -Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.5 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 07:59:29 2013 From: report at bugs.python.org (Ezio Melotti) Date: Tue, 06 Aug 2013 05:59:29 +0000 Subject: [issue16245] Update html.entities.html5 dictionary and parseentities.py In-Reply-To: <1350380511.49.0.860998010837.issue16245@psf.upfronthosting.co.za> Message-ID: <1375768769.22.0.642534431038.issue16245@psf.upfronthosting.co.za> Ezio Melotti added the comment: I run Tools/scripts/parse_html5_entities.py and it says that "The current dictionary is updated.". We should check this again, and eventually close the issue, when 3.4 is released. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 08:09:19 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Tue, 06 Aug 2013 06:09:19 +0000 Subject: [issue18665] Typos in frame object related code In-Reply-To: <1375764800.58.0.482122024787.issue18665@psf.upfronthosting.co.za> Message-ID: <1375769359.77.0.775522715572.issue18665@psf.upfronthosting.co.za> Vajrasky Kok added the comment: Okay, attached the patch to fix the typo. ---------- keywords: +patch Added file: http://bugs.python.org/file31171/fix_typo_frame_object.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 08:12:13 2013 From: report at bugs.python.org (Ezio Melotti) Date: Tue, 06 Aug 2013 06:12:13 +0000 Subject: [issue18562] Regex howto: revision pass In-Reply-To: <1374854855.56.0.787824851556.issue18562@psf.upfronthosting.co.za> Message-ID: <1375769533.04.0.899115816134.issue18562@psf.upfronthosting.co.za> Changes by Ezio Melotti : ---------- components: +Regular Expressions nosy: +mrabarnett type: -> enhancement _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 08:54:47 2013 From: report at bugs.python.org (Petr.Salinger) Date: Tue, 06 Aug 2013 06:54:47 +0000 Subject: [issue18667] missing HAVE_FCHOWNAT Message-ID: <1375772087.0.0.361755653525.issue18667@psf.upfronthosting.co.za> New submission from Petr.Salinger: During test on kfreebsd: test_chown_dir_fd (test.test_posix.PosixTester) ... skipped 'test needs dir_fd support in os.chown()' But all *AT syscalls are supported. It looks like posixmodule.c misses propagation of that fact. --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -12004,6 +12004,10 @@ "HAVE_FCHOWN", #endif +#ifdef HAVE_FCHOWNAT + "HAVE_FCHOWNAT", +#endif + #ifdef HAVE_FEXECVE "HAVE_FEXECVE", #endif ---------- components: Extension Modules messages: 194529 nosy: Petr.Salinger priority: normal severity: normal status: open title: missing HAVE_FCHOWNAT versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 09:42:57 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Tue, 06 Aug 2013 07:42:57 +0000 Subject: [issue18468] re.group() should never return a bytearray In-Reply-To: <1373931432.85.0.594082146564.issue18468@psf.upfronthosting.co.za> Message-ID: <1375774977.24.0.590723358398.issue18468@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: Here is a patch with an implementation and tests. Feel free to add a documentation changes if needed. ---------- stage: needs patch -> patch review _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 10:23:57 2013 From: report at bugs.python.org (salinger) Date: Tue, 06 Aug 2013 08:23:57 +0000 Subject: [issue18667] missing HAVE_FCHOWNAT In-Reply-To: <1375772087.0.0.361755653525.issue18667@psf.upfronthosting.co.za> Message-ID: <1375777437.06.0.995202602908.issue18667@psf.upfronthosting.co.za> Changes by salinger : ---------- nosy: +doko _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 10:52:02 2013 From: report at bugs.python.org (Roundup Robot) Date: Tue, 06 Aug 2013 08:52:02 +0000 Subject: [issue14323] Normalize math precision in RGB/YIQ conversion In-Reply-To: <1331831977.5.0.174772346075.issue14323@psf.upfronthosting.co.za> Message-ID: <3c8V2n58BNzRFT@mail.python.org> Roundup Robot added the comment: New changeset 80e9cb6163b4 by Serhiy Storchaka in branch 'default': Issue #14323: Expanded the number of digits in the coefficients for the http://hg.python.org/cpython/rev/80e9cb6163b4 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 10:53:04 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Tue, 06 Aug 2013 08:53:04 +0000 Subject: [issue14323] Normalize math precision in RGB/YIQ conversion In-Reply-To: <1331831977.5.0.174772346075.issue14323@psf.upfronthosting.co.za> Message-ID: <1375779184.54.0.229549014033.issue14323@psf.upfronthosting.co.za> Changes by Serhiy Storchaka : ---------- resolution: -> fixed stage: commit review -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 11:03:26 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Tue, 06 Aug 2013 09:03:26 +0000 Subject: [issue18368] PyOS_StdioReadline() leaks memory when realloc() fails In-Reply-To: <1373054563.49.0.685653845765.issue18368@psf.upfronthosting.co.za> Message-ID: <1375779806.1.0.106585093285.issue18368@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: The patch can be a little simplified (the "else" keyword is redundant), but in general it LGTM. Let's push. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 13:50:06 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Tue, 06 Aug 2013 11:50:06 +0000 Subject: [issue16968] Fix test discovery for test_concurrent_futures.py In-Reply-To: <1358201974.23.0.0352259739582.issue16968@psf.upfronthosting.co.za> Message-ID: <1375789806.76.0.676540869096.issue16968@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: As far as I understand threads reaping needed only when ThreadPoolExecutor is used and children reaping needed only when ProcessPoolExecutor is used. Why not use them only in tests which needs them? class ThreadPoolMixin(ExecutorMixin): executor_type = futures.ThreadPoolExecutor def run(self, result): key = test.support.threading_setup() try: return super().run(result) finally: test.support.threading_cleanup(*key) class ProcessPoolMixin(ExecutorMixin): executor_type = futures.ProcessPoolExecutor def run(self, result): try: return super().run(result) finally: test.support.reap_children() ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 13:51:34 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Tue, 06 Aug 2013 11:51:34 +0000 Subject: [issue18430] gzip, bz2, lzma: peek advances file position of existing file object In-Reply-To: <1373571241.88.0.314815867736.issue18430@psf.upfronthosting.co.za> Message-ID: <1375789894.04.0.17114502289.issue18430@psf.upfronthosting.co.za> Changes by Serhiy Storchaka : ---------- nosy: -serhiy.storchaka _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 13:53:32 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Tue, 06 Aug 2013 11:53:32 +0000 Subject: [issue18528] Possible fd leak in socketmodule In-Reply-To: <1374496496.68.0.51305379842.issue18528@psf.upfronthosting.co.za> Message-ID: <1375790012.56.0.917956680553.issue18528@psf.upfronthosting.co.za> Changes by Serhiy Storchaka : ---------- nosy: -serhiy.storchaka _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 13:56:51 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Tue, 06 Aug 2013 11:56:51 +0000 Subject: [issue15301] os.chown: OverflowError: Python int too large to convert to C long In-Reply-To: <1341800139.98.0.546402243809.issue15301@psf.upfronthosting.co.za> Message-ID: <1375790211.79.0.135368924992.issue15301@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: Let's push. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 14:11:33 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Tue, 06 Aug 2013 12:11:33 +0000 Subject: [issue18301] In itertools.chain.from_iterable() there is no cls argument In-Reply-To: <1372186723.21.0.67533324157.issue18301@psf.upfronthosting.co.za> Message-ID: <1375791093.74.0.585284037721.issue18301@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: It should be a classmethod. >>> import itertools >>> class C(itertools.chain): pass ... >>> type(C.from_iterable(['ab', 'cd'])) The patch LGTM. ---------- assignee: docs at python -> serhiy.storchaka stage: -> commit review _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 14:17:06 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Tue, 06 Aug 2013 12:17:06 +0000 Subject: [issue18301] In itertools.chain.from_iterable() there is no cls argument In-Reply-To: <1372186723.21.0.67533324157.issue18301@psf.upfronthosting.co.za> Message-ID: <1375791426.57.0.60996685049.issue18301@psf.upfronthosting.co.za> Changes by Serhiy Storchaka : ---------- assignee: serhiy.storchaka -> rhettinger _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 14:18:46 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Tue, 06 Aug 2013 12:18:46 +0000 Subject: [issue14507] Segfault with deeply nested starmap calls In-Reply-To: <1333628918.06.0.633986455545.issue14507@psf.upfronthosting.co.za> Message-ID: <1375791526.77.0.0400575873522.issue14507@psf.upfronthosting.co.za> Changes by Serhiy Storchaka : ---------- status: open -> pending _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 14:19:33 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Tue, 06 Aug 2013 12:19:33 +0000 Subject: [issue11126] Wave.py does not always write proper length in header In-Reply-To: <1296864048.5.0.627671615909.issue11126@psf.upfronthosting.co.za> Message-ID: <1375791573.25.0.349704065678.issue11126@psf.upfronthosting.co.za> Changes by Serhiy Storchaka : ---------- status: open -> pending _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 14:23:49 2013 From: report at bugs.python.org (Ethan Furman) Date: Tue, 06 Aug 2013 12:23:49 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375791829.11.0.689232613813.issue18264@psf.upfronthosting.co.za> Ethan Furman added the comment: Hopefully the final patch. :) ---------- Added file: http://bugs.python.org/file31172/issue18264.stoneleaf.04.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 14:29:27 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Tue, 06 Aug 2013 12:29:27 +0000 Subject: [issue18290] json encoder does not support JSONP/JavaScript safe escaping In-Reply-To: <1372049179.79.0.237326954931.issue18290@psf.upfronthosting.co.za> Message-ID: <1375792167.0.0.931522681563.issue18290@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: I think this is not JSON issue. If you need escaping of some domain-specific characters, do it youself. I.e. json.dump(...).replace('\u2028', r'\u2028').replace('\u2029', r'\u2029').replace(' invalid status: open -> pending _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 15:02:47 2013 From: report at bugs.python.org (Mark Dickinson) Date: Tue, 06 Aug 2013 13:02:47 +0000 Subject: [issue15966] concurrent.futures: Executor.submit keyword arguments may not be called 'fn' (or 'self') In-Reply-To: <1347982368.75.0.56994107832.issue15966@psf.upfronthosting.co.za> Message-ID: <1375794167.05.0.505719114696.issue15966@psf.upfronthosting.co.za> Mark Dickinson added the comment: Closing this. ---------- resolution: -> wont fix status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 15:06:06 2013 From: report at bugs.python.org (Ethan Furman) Date: Tue, 06 Aug 2013 13:06:06 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375794366.42.0.960584568193.issue18264@psf.upfronthosting.co.za> Ethan Furman added the comment: Forgot to back out core dump tests before creating previous patch. This one even passes the tests. :/ ---------- Added file: http://bugs.python.org/file31173/issue18264.stoneleaf.05.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 15:09:28 2013 From: report at bugs.python.org (Mark Dickinson) Date: Tue, 06 Aug 2013 13:09:28 +0000 Subject: [issue10918] **kwargs unnecessarily restricted in concurrent.futures 'submit' API In-Reply-To: <1295192992.12.0.880697566702.issue10918@psf.upfronthosting.co.za> Message-ID: <1375794568.33.0.778559718235.issue10918@psf.upfronthosting.co.za> Mark Dickinson added the comment: #15966 is related. I suggest closing this issue as "won't fix", too. ---------- nosy: +mark.dickinson _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 15:11:31 2013 From: report at bugs.python.org (Eli Bendersky) Date: Tue, 06 Aug 2013 13:11:31 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375794691.86.0.296518308907.issue18264@psf.upfronthosting.co.za> Eli Bendersky added the comment: LGTM now. Make sure to run the test(s) in refleak mode and let's wait for a couple of days before committing, in case someone else has comments. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 15:16:58 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Tue, 06 Aug 2013 13:16:58 +0000 Subject: [issue1772673] Replacing char* with const char* Message-ID: <1375795018.06.0.221837514959.issue1772673@psf.upfronthosting.co.za> Changes by Serhiy Storchaka : ---------- assignee: -> serhiy.storchaka _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 15:20:46 2013 From: report at bugs.python.org (Eli Bendersky) Date: Tue, 06 Aug 2013 13:20:46 +0000 Subject: [issue18668] Properly document setting m_size in PyModuleDef Message-ID: <1375795246.61.0.949649493069.issue18668@psf.upfronthosting.co.za> New submission from Eli Bendersky: docs.python.org/dev/c-api/module.html Currently doesn't say much about m_size, except that setting it to -1 means "no memory needed". m_size == -1 has a much more important use that is not documented: it signals the import machinery that the module should not be ever re-initialized. This has to be documented explicitly. ---------- assignee: eli.bendersky components: Documentation, Extension Modules messages: 194542 nosy: eli.bendersky, ncoghlan priority: normal severity: normal stage: needs patch status: open title: Properly document setting m_size in PyModuleDef type: behavior versions: Python 3.3, Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 15:20:58 2013 From: report at bugs.python.org (Eli Bendersky) Date: Tue, 06 Aug 2013 13:20:58 +0000 Subject: [issue18668] Properly document setting m_size in PyModuleDef In-Reply-To: <1375795246.61.0.949649493069.issue18668@psf.upfronthosting.co.za> Message-ID: <1375795258.98.0.269625517272.issue18668@psf.upfronthosting.co.za> Changes by Eli Bendersky : ---------- nosy: +loewis _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 15:28:47 2013 From: report at bugs.python.org (Mark Dickinson) Date: Tue, 06 Aug 2013 13:28:47 +0000 Subject: [issue15966] concurrent.futures: Executor.submit keyword arguments may not be called 'fn' (or 'self') In-Reply-To: <1347982368.75.0.56994107832.issue15966@psf.upfronthosting.co.za> Message-ID: <1375795727.36.0.962273806034.issue15966@psf.upfronthosting.co.za> Changes by Mark Dickinson : ---------- resolution: wont fix -> duplicate superseder: -> **kwargs unnecessarily restricted in concurrent.futures 'submit' API _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 15:41:14 2013 From: report at bugs.python.org (Ethan Furman) Date: Tue, 06 Aug 2013 13:41:14 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1375794691.86.0.296518308907.issue18264@psf.upfronthosting.co.za> Message-ID: <5200FCF8.60005@stoneleaf.us> Ethan Furman added the comment: I'll plan on committing no sooner than Friday unless somebody else has comments/corrections. Thanks, Eli. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 15:48:51 2013 From: report at bugs.python.org (James Laver) Date: Tue, 06 Aug 2013 13:48:51 +0000 Subject: [issue18662] re.escape should not escape the hyphen In-Reply-To: <1375722644.22.0.61356481393.issue18662@psf.upfronthosting.co.za> Message-ID: <1375796931.79.0.704483092194.issue18662@psf.upfronthosting.co.za> James Laver added the comment: I looked up quotemeta with perldoc and you're right, it will quote the hyphen. Given that python's regex engine correctly deals with unnecessarily quoted characters, I suppose this is fine. ---------- resolution: -> wont fix status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 15:52:44 2013 From: report at bugs.python.org (Christian Heimes) Date: Tue, 06 Aug 2013 13:52:44 +0000 Subject: [issue18532] hashlib.HASH objects should officially expose the hash name In-Reply-To: <1374524940.42.0.582552143445.issue18532@psf.upfronthosting.co.za> Message-ID: <1375797164.08.0.200307992783.issue18532@psf.upfronthosting.co.za> Christian Heimes added the comment: I added some tests in 5fbf23e947d8 and found a bug in the _sha1 module, too. ---------- status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 15:53:43 2013 From: report at bugs.python.org (Oscar Benjamin) Date: Tue, 06 Aug 2013 13:53:43 +0000 Subject: [issue18606] Add statistics module to standard library In-Reply-To: <1375258820.22.0.0684222529612.issue18606@psf.upfronthosting.co.za> Message-ID: <1375797223.05.0.687836175495.issue18606@psf.upfronthosting.co.za> Changes by Oscar Benjamin : ---------- nosy: +oscarbenjamin _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 15:57:03 2013 From: report at bugs.python.org (Roundup Robot) Date: Tue, 06 Aug 2013 13:57:03 +0000 Subject: [issue15866] encode(..., 'xmlcharrefreplace') produces entities for surrogate pairs In-Reply-To: <1346871274.13.0.653364801762.issue15866@psf.upfronthosting.co.za> Message-ID: <3c8cpk2hf1z7LlP@mail.python.org> Roundup Robot added the comment: New changeset 719ee60fc5e2 by Serhiy Storchaka in branch '2.7': Issue #15866: The xmlcharrefreplace error handler no more produces two XML http://hg.python.org/cpython/rev/719ee60fc5e2 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 15:58:20 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Tue, 06 Aug 2013 13:58:20 +0000 Subject: [issue15866] encode(..., 'xmlcharrefreplace') produces entities for surrogate pairs In-Reply-To: <1346871274.13.0.653364801762.issue15866@psf.upfronthosting.co.za> Message-ID: <1375797500.33.0.418346960318.issue15866@psf.upfronthosting.co.za> Changes by Serhiy Storchaka : ---------- assignee: -> serhiy.storchaka resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 16:03:46 2013 From: report at bugs.python.org (Roundup Robot) Date: Tue, 06 Aug 2013 14:03:46 +0000 Subject: [issue18368] PyOS_StdioReadline() leaks memory when realloc() fails In-Reply-To: <1373054563.49.0.685653845765.issue18368@psf.upfronthosting.co.za> Message-ID: <3c8cyT6xLfz7Lm8@mail.python.org> Roundup Robot added the comment: New changeset 5859a3ec5b7e by Christian Heimes in branch '3.3': Issue #18368: PyOS_StdioReadline() no longer leaks memory when realloc() fails. http://hg.python.org/cpython/rev/5859a3ec5b7e New changeset 6dbc4d6ff31e by Christian Heimes in branch 'default': Issue #18368: PyOS_StdioReadline() no longer leaks memory when realloc() fails. http://hg.python.org/cpython/rev/6dbc4d6ff31e ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 16:06:12 2013 From: report at bugs.python.org (Eli Bendersky) Date: Tue, 06 Aug 2013 14:06:12 +0000 Subject: [issue18668] Properly document setting m_size in PyModuleDef In-Reply-To: <1375795246.61.0.949649493069.issue18668@psf.upfronthosting.co.za> Message-ID: <1375797972.79.0.437136695008.issue18668@psf.upfronthosting.co.za> Eli Bendersky added the comment: Here's a documentation patch generated for 3.3 ---------- keywords: +patch Added file: http://bugs.python.org/file31174/issue18668.doc.1.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 16:16:12 2013 From: report at bugs.python.org (Christian Heimes) Date: Tue, 06 Aug 2013 14:16:12 +0000 Subject: [issue18368] PyOS_StdioReadline() leaks memory when realloc() fails In-Reply-To: <1373054563.49.0.685653845765.issue18368@psf.upfronthosting.co.za> Message-ID: <1375798572.68.0.832506459831.issue18368@psf.upfronthosting.co.za> Christian Heimes added the comment: Serhiy: Thanks for the review Kristj?n: Yes, it's enough to check for incr > INT_MAX. The buffer size is incremented to a value of <= (2*n)+2 in each round. The start value is 100. The loop is terminated once the buffer size reaches INT_MAX-2. ---------- resolution: -> fixed stage: patch review -> committed/rejected status: open -> pending _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 16:16:48 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Tue, 06 Aug 2013 14:16:48 +0000 Subject: [issue18668] Properly document setting m_size in PyModuleDef In-Reply-To: <1375795246.61.0.949649493069.issue18668@psf.upfronthosting.co.za> Message-ID: <1375798608.36.0.881327276282.issue18668@psf.upfronthosting.co.za> Antoine Pitrou added the comment: Looks good to me, thanks. ---------- nosy: +pitrou _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 16:21:50 2013 From: report at bugs.python.org (Christian Heimes) Date: Tue, 06 Aug 2013 14:21:50 +0000 Subject: [issue16038] ftplib: unlimited readline() from connection In-Reply-To: <1348569175.14.0.867789583045.issue16038@psf.upfronthosting.co.za> Message-ID: <1375798910.29.0.173526525467.issue16038@psf.upfronthosting.co.za> Christian Heimes added the comment: The patches are languishing in the bug tracker for a while... Benjamin: I like to apply them to 3.3 and default before the next release of 3.3. Do you want to have the fixes in 2.7, too? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 16:42:50 2013 From: report at bugs.python.org (productivememberofsociety666) Date: Tue, 06 Aug 2013 14:42:50 +0000 Subject: [issue18669] curses.chgat() moves cursor, documentation says it shouldn't Message-ID: <1375800170.73.0.20062232661.issue18669@psf.upfronthosting.co.za> New submission from productivememberofsociety666: According to docs.python.org/2/library/curses.html#chgat (or any other version), curses.chgat() is not supposed to move the cursor at all. This is true if you don't give it x,y coordinates, but if you do, the cursor does in fact move to those coordinates, since it then uses C curses's mvchgat() internally and doesn't correct the position afterwards. See included file for demonstration: Expected output is: one two Actual output is: two Fix the documentation or fix the code :-) ---------- assignee: docs at python components: Documentation, Extension Modules files: chgat-bug.py messages: 194552 nosy: docs at python, productivememberofsociety666 priority: normal severity: normal status: open title: curses.chgat() moves cursor, documentation says it shouldn't type: behavior versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5 Added file: http://bugs.python.org/file31175/chgat-bug.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 16:45:30 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Tue, 06 Aug 2013 14:45:30 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375800330.16.0.125125679589.issue18647@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: Originally the catch condition was (lo == 0). It was changed in changeset 41c42b1bd582. > Offhand, do you have an example that displays bad behavior in 2.7? I'm curious because I didn't find one after half an hour of trying. re.match('(?:.?.?)*y', 'x'*20) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 16:48:58 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Tue, 06 Aug 2013 14:48:58 +0000 Subject: [issue16741] `int()`, `float()`, etc think python strings are null-terminated In-Reply-To: <1356046641.74.0.314140910069.issue16741@psf.upfronthosting.co.za> Message-ID: <1375800538.82.0.0554303593491.issue16741@psf.upfronthosting.co.za> Changes by Serhiy Storchaka : ---------- resolution: -> fixed status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 16:50:28 2013 From: report at bugs.python.org (Ethan Furman) Date: Tue, 06 Aug 2013 14:50:28 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1375794691.86.0.296518308907.issue18264@psf.upfronthosting.co.za> Message-ID: <52010D32.70206@stoneleaf.us> Ethan Furman added the comment: > Eli Bendersky added the comment: > > Make sure to run the test(s) in refleak mode . . . How extensive should testing be? I plan on always running the refleak mode tests (now that I know how ;) . Should I also run non-refleak tests? Should I run tests with a python built without --with-pydebug? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 17:16:27 2013 From: report at bugs.python.org (Brett Cannon) Date: Tue, 06 Aug 2013 15:16:27 +0000 Subject: [issue18416] Move to absolute file paths for module.__file__ In-Reply-To: <1373400107.5.0.285657244525.issue18416@psf.upfronthosting.co.za> Message-ID: <1375802187.73.0.654105025133.issue18416@psf.upfronthosting.co.za> Brett Cannon added the comment: I actually meant FileFinder but PathFinder is a good point. In FileFinder you need to change ``self.path = path or '.'`` to use the cwd. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 17:26:13 2013 From: report at bugs.python.org (Ezio Melotti) Date: Tue, 06 Aug 2013 15:26:13 +0000 Subject: [issue18662] re.escape should not escape the hyphen In-Reply-To: <1375722644.22.0.61356481393.issue18662@psf.upfronthosting.co.za> Message-ID: <1375802773.33.0.424924132347.issue18662@psf.upfronthosting.co.za> Changes by Ezio Melotti : ---------- stage: -> committed/rejected _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 17:31:35 2013 From: report at bugs.python.org (Eli Bendersky) Date: Tue, 06 Aug 2013 15:31:35 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375803095.54.0.635444918154.issue18264@psf.upfronthosting.co.za> Eli Bendersky added the comment: IMHO it's very much dependent on the change. When making C code changes, I usually run the relevant tests with refleaks, and then run the whole test suite; all of this --with-pydebug. Personally I've not encountered cases where non-debug builds failed where debug suceeded for CPython, but for very significant changes I may do some extra runs in the release mode as well (or try to test it on a specific OS). It's very important to watch the bots after committing, because they run a wide variety of configurations you'll be hard pressed to reproduce on your own - so they exercise the change pretty well. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 17:31:44 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Tue, 06 Aug 2013 15:31:44 +0000 Subject: [issue18670] Using read_mime_types function from mimetypes module gives resource warning Message-ID: <1375803104.23.0.740839065527.issue18670@psf.upfronthosting.co.za> New submission from Vajrasky Kok: [sky at localhost cpython]$ cat /tmp/a.txt x-application/mimea mimea application/mimeb mimeb [sky at localhost cpython]$ cat /tmp/a.py import warnings warnings.simplefilter('default') import mimetypes mimetypes.read_mime_types('/tmp/a.txt') [sky at localhost cpython]$ python3 /tmp/a.py /tmp/a.py:7: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/a.txt' mode='r' encoding='UTF-8'> mimetypes.read_mime_types('/tmp/a.txt') Attached the patch to fix the resource warning problem. ---------- components: Library (Lib) files: fix_resource_warning_read_mime_types.patch keywords: patch messages: 194557 nosy: vajrasky priority: normal severity: normal status: open title: Using read_mime_types function from mimetypes module gives resource warning type: resource usage versions: Python 3.4 Added file: http://bugs.python.org/file31176/fix_resource_warning_read_mime_types.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 17:33:57 2013 From: report at bugs.python.org (Ezio Melotti) Date: Tue, 06 Aug 2013 15:33:57 +0000 Subject: [issue18264] enum.IntEnum is not compatible with JSON serialisation In-Reply-To: <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za> Message-ID: <1375803237.51.0.992222778698.issue18264@psf.upfronthosting.co.za> Ezio Melotti added the comment: > I plan on always running the refleak mode tests (now that I know how ;) FWIW `make patchcheck` should remind you about that. ---------- stage: -> patch review type: -> enhancement _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 17:57:49 2013 From: report at bugs.python.org (M. Dietrich) Date: Tue, 06 Aug 2013 15:57:49 +0000 Subject: [issue18671] enhance formatting in logging package Message-ID: <1375804669.84.0.0477385788117.issue18671@psf.upfronthosting.co.za> New submission from M. Dietrich: in logging/__init__.py line 328 there is a simple line: msg = msg % self.args if that line fails this failure will be logged, not the line itself. i suggest to change the line to something like: try: msg = msg % self.args except TypeError: msg = 'logging formatting error with "%s" %% %s' % ( msg, self.args, ) to be able to pinpoint the actual wrong formatting string (the stack trace doesnt help here). ---------- components: Extension Modules messages: 194559 nosy: mdt priority: normal severity: normal status: open title: enhance formatting in logging package type: enhancement _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 18:07:46 2013 From: report at bugs.python.org (Madison May) Date: Tue, 06 Aug 2013 16:07:46 +0000 Subject: [issue18416] Move to absolute file paths for module.__file__ In-Reply-To: <1373400107.5.0.285657244525.issue18416@psf.upfronthosting.co.za> Message-ID: <1375805266.28.0.128618982976.issue18416@psf.upfronthosting.co.za> Madison May added the comment: A few days ago I tried the change: ``self.path = path or _os.cwd()``, but the problem didn't seem to resolve itself. ``./python -c "import blah; print(blah.__file__)`` still returned a relative path on my system. The tie between FileFinder and the __file__ attribute isn't yet obvious to me. I'm traveling for the next few days but I'll probably give it a second look when I get some free time. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 18:11:58 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Tue, 06 Aug 2013 16:11:58 +0000 Subject: [issue18672] Fix format specifiers for debug output in _sre.c Message-ID: <1375805518.91.0.887667887132.issue18672@psf.upfronthosting.co.za> New submission from Serhiy Storchaka: When the VERBOSE macro name is defined in _sre.c the TRACE macro prints regex processing trace. It use the %d format specifier for Py_ssize_t values. This can crash on 64-bit. Proposed patch fixes format strings. ---------- components: Regular Expressions files: re_trace_format.patch keywords: patch messages: 194561 nosy: ezio.melotti, mrabarnett, serhiy.storchaka priority: normal severity: normal stage: patch review status: open title: Fix format specifiers for debug output in _sre.c type: behavior versions: Python 2.7, Python 3.3, Python 3.4 Added file: http://bugs.python.org/file31177/re_trace_format.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 18:13:42 2013 From: report at bugs.python.org (Igor Skochinsky) Date: Tue, 06 Aug 2013 16:13:42 +0000 Subject: [issue17213] ctypes loads wrong version of C runtime, leading to error message box from system In-Reply-To: <1360992800.86.0.617349310494.issue17213@psf.upfronthosting.co.za> Message-ID: <1375805622.66.0.310299802378.issue17213@psf.upfronthosting.co.za> Igor Skochinsky added the comment: Just had this issue when using networkx (which imports uuid). One keyword that would help visibility is R6034 (the runtime error number). A couple of reports related to this: https://projects.blender.org/tracker/index.php?func=detail&aid=27666 http://forums.boxee.tv/showthread.php?t=15425 The proper solution is to fix ctypes, but in the meantime we can at least fix uuid. The error seems to be triggered by this snippet: # The uuid_generate_* routines are provided by libuuid on at least # Linux and FreeBSD, and provided by libc on Mac OS X. for libname in ['uuid', 'c']: try: lib = ctypes.CDLL(ctypes.util.find_library(libname)) except: continue if hasattr(lib, 'uuid_generate_random'): _uuid_generate_random = lib.uuid_generate_random if hasattr(lib, 'uuid_generate_time'): _uuid_generate_time = lib.uuid_generate_time Since this code is useless on Windows, protecting it in "if os.name not in ['nt', 'ce']" does the trick. BTW, instead of going all way with activation context etc., a simpler solution would be to add to ctypes something like this in CDLL.__init__: if os.name in ['nt', 'ce'] and name == util.find_msvcrt(): # TODO: handle the extension self._handle = windll.kernel32.GetModuleHandleA(self._name) i.e. use the already present runtime DLL instead of trying to load it again. ---------- nosy: +Igor.Skochinsky _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 18:18:29 2013 From: report at bugs.python.org (Matthew Barnett) Date: Tue, 06 Aug 2013 16:18:29 +0000 Subject: [issue18662] re.escape should not escape the hyphen In-Reply-To: <1375722644.22.0.61356481393.issue18662@psf.upfronthosting.co.za> Message-ID: <1375805908.99.0.825687908285.issue18662@psf.upfronthosting.co.za> Matthew Barnett added the comment: I can think of a real disadvantage with the current behaviour: it messes up Unicode graphemes. For example: >>> print('??????') ?????? >>> print(re.escape('??????')) \?\?\?\?\?\? Of course, that's only a problem if you need to print it out or write it to a file. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 18:25:45 2013 From: report at bugs.python.org (productivememberofsociety666) Date: Tue, 06 Aug 2013 16:25:45 +0000 Subject: [issue18669] curses.chgat() moves cursor, documentation says it shouldn't In-Reply-To: <1375800170.73.0.20062232661.issue18669@psf.upfronthosting.co.za> Message-ID: <1375806345.41.0.430600505498.issue18669@psf.upfronthosting.co.za> Changes by productivememberofsociety666 : Removed file: http://bugs.python.org/file31175/chgat-bug.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 18:26:45 2013 From: report at bugs.python.org (productivememberofsociety666) Date: Tue, 06 Aug 2013 16:26:45 +0000 Subject: [issue18669] curses.chgat() moves cursor, documentation says it shouldn't In-Reply-To: <1375800170.73.0.20062232661.issue18669@psf.upfronthosting.co.za> Message-ID: <1375806405.68.0.415112252943.issue18669@psf.upfronthosting.co.za> Changes by productivememberofsociety666 : Added file: http://bugs.python.org/file31178/chgat-bug.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 18:43:32 2013 From: report at bugs.python.org (Ezio Melotti) Date: Tue, 06 Aug 2013 16:43:32 +0000 Subject: [issue13153] IDLE crashes when pasting non-BMP unicode char on Py3 In-Reply-To: <1318363292.9.0.682519731008.issue13153@psf.upfronthosting.co.za> Message-ID: <1375807412.04.0.47920246774.issue13153@psf.upfronthosting.co.za> Ezio Melotti added the comment: 0xed is the start byte of a 3 bytes sequence (i.e. a BMP char), and it should be followed by two continuation bytes. For some reason the traceback you pasted is missing the last part, that might provide some insight. It could be one of these: >>> b'\xed'.decode('utf-8') # not enough continuation bytes UnicodeDecodeError: 'utf-8' codec can't decode byte 0xed in position 0: unexpected end of data >>> b'\xed\x7f'.decode('utf-8') # not a valid continuation byte UnicodeDecodeError: 'utf-8' codec can't decode byte 0xed in position 0: invalid continuation byte ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 18:52:37 2013 From: report at bugs.python.org (Roundup Robot) Date: Tue, 06 Aug 2013 16:52:37 +0000 Subject: [issue18443] Misc/Readme still documents TextMate In-Reply-To: <1373775366.01.0.177392157148.issue18443@psf.upfronthosting.co.za> Message-ID: <3c8hjJ1fjSz7Lm0@mail.python.org> Roundup Robot added the comment: New changeset 5c74755e8f04 by Ezio Melotti in branch 'default': #18443: remove the TextMate entry now that the bundle has been removed and fix ordering. Patch by F?vry Thibault. http://hg.python.org/cpython/rev/5c74755e8f04 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 18:53:04 2013 From: report at bugs.python.org (Ezio Melotti) Date: Tue, 06 Aug 2013 16:53:04 +0000 Subject: [issue18443] Misc/Readme still documents TextMate In-Reply-To: <1373775366.01.0.177392157148.issue18443@psf.upfronthosting.co.za> Message-ID: <1375807984.44.0.67982372644.issue18443@psf.upfronthosting.co.za> Ezio Melotti added the comment: Fixed, thanks for the report and the patch! ---------- assignee: docs at python -> ezio.melotti resolution: -> fixed stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 18:55:14 2013 From: report at bugs.python.org (R. David Murray) Date: Tue, 06 Aug 2013 16:55:14 +0000 Subject: [issue18671] enhance formatting in logging package In-Reply-To: <1375804669.84.0.0477385788117.issue18671@psf.upfronthosting.co.za> Message-ID: <1375808114.41.0.965181812723.issue18671@psf.upfronthosting.co.za> Changes by R. David Murray : ---------- nosy: +vinay.sajip _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 18:58:35 2013 From: report at bugs.python.org (Ezio Melotti) Date: Tue, 06 Aug 2013 16:58:35 +0000 Subject: [issue18383] test_warnings modifies warnings.filters when running with "-W default" In-Reply-To: <1373117774.47.0.846306714059.issue18383@psf.upfronthosting.co.za> Message-ID: <1375808315.73.0.73503694237.issue18383@psf.upfronthosting.co.za> Ezio Melotti added the comment: LGTM ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 19:04:52 2013 From: report at bugs.python.org (Tim Peters) Date: Tue, 06 Aug 2013 17:04:52 +0000 Subject: [issue18647] re.error: nothing to repeat In-Reply-To: <1375562527.29.0.365652198395.issue18647@psf.upfronthosting.co.za> Message-ID: <1375808692.73.0.232469988316.issue18647@psf.upfronthosting.co.za> Tim Peters added the comment: Serhiy, yup, that regexp is slow, but it does finish - so the engine is doing something to avoid _unbounded_ repetitive matching of an empty string. Change it to (?:.?.+)*y and the group can no longer match an empty string, but it's still slow (although about 3x faster, it's still exponential in the length of the string it fails to match). ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 21:43:40 2013 From: report at bugs.python.org (Christian Heimes) Date: Tue, 06 Aug 2013 19:43:40 +0000 Subject: [issue18673] Add and use O_TMPFILE for Linux 3.11 Message-ID: <1375818220.16.0.883591943761.issue18673@psf.upfronthosting.co.za> New submission from Christian Heimes: Linux 3.11 gets a new flag for open(): Quote from http://lwn.net/Articles/557314/ --- The new O_TMPFILE option to the open() and openat() system calls allows filesystems to optimize the creation of temporary files ? files which need not be visible in the filesystem. When O_TMPFILE is present, the provided pathname is only used to locate the containing directory (and thus the filesystem where the temporary file should be). So, among other things, programs using O_TMPFILE should have fewer concerns about vulnerabilities resulting from symbolic link attacks. --- Tasks: - add O_TEMPFILE to posixmodule.c - use O_TEMPFILE in tempfile module when it's supported by the current kernel ---------- components: Extension Modules, Library (Lib) messages: 194569 nosy: christian.heimes priority: normal severity: normal stage: needs patch status: open title: Add and use O_TMPFILE for Linux 3.11 type: enhancement versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 22:29:39 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Tue, 06 Aug 2013 20:29:39 +0000 Subject: [issue15651] PEP 3121, 384 refactoring applied to elementtree module In-Reply-To: <1344968721.44.0.689766020196.issue15651@psf.upfronthosting.co.za> Message-ID: <1375820979.0.0.328962266779.issue15651@psf.upfronthosting.co.za> Antoine Pitrou added the comment: Here is a simplified patch tackling only the PEP 3121 compliance. Eli, I think this would be good to go. ---------- Added file: http://bugs.python.org/file31179/etree_3121.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 22:38:51 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Tue, 06 Aug 2013 20:38:51 +0000 Subject: [issue18674] Store weak references in modules_by_index Message-ID: <1375821531.36.0.318072139637.issue18674@psf.upfronthosting.co.za> New submission from Antoine Pitrou: modules_by_index is a near-eternal store for extension modules. It is only collected at the end of interpreter shutdown, which is much too late for regular garbage collection. This patch proposes instead to store weak references in modules_by_index, so that extension modules can be collected in a normal way when they are removed from sys.modules. The only gotcha is that PyState_FindModule returns a borrowed reference. With this change, it becomes really important to incref the returned reference as soon as possible. ---------- components: Interpreter Core files: wr_module_state.patch keywords: patch messages: 194571 nosy: brett.cannon, eric.snow, loewis, ncoghlan, pitrou, sbt priority: normal severity: normal stage: patch review status: open title: Store weak references in modules_by_index type: resource usage versions: Python 3.4 Added file: http://bugs.python.org/file31180/wr_module_state.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 22:57:38 2013 From: report at bugs.python.org (Roundup Robot) Date: Tue, 06 Aug 2013 20:57:38 +0000 Subject: [issue18621] site.py keeps too much stuff alive when it patches builtins In-Reply-To: <1375390196.76.0.0867903823381.issue18621@psf.upfronthosting.co.za> Message-ID: <3c8p813xg8z7Lld@mail.python.org> Roundup Robot added the comment: New changeset 8584f63e570e by Antoine Pitrou in branch 'default': Issue #18621: Prevent the site module's patched builtins from keeping too many references alive for too long. http://hg.python.org/cpython/rev/8584f63e570e ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 22:59:05 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Tue, 06 Aug 2013 20:59:05 +0000 Subject: [issue18621] site.py keeps too much stuff alive when it patches builtins In-Reply-To: <1375390196.76.0.0867903823381.issue18621@psf.upfronthosting.co.za> Message-ID: <1375822745.83.0.227381226171.issue18621@psf.upfronthosting.co.za> Antoine Pitrou added the comment: I went ahead and committed this, so that the effect of other improvements in the area stand out better. ---------- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 23:05:31 2013 From: report at bugs.python.org (Roundup Robot) Date: Tue, 06 Aug 2013 21:05:31 +0000 Subject: [issue18666] Unused variable in test_frame.py In-Reply-To: <1375765297.44.0.682936392521.issue18666@psf.upfronthosting.co.za> Message-ID: <3c8pK650YNz7LkN@mail.python.org> Roundup Robot added the comment: New changeset 34e1ecb8edd2 by Antoine Pitrou in branch 'default': Issue #18666: improve test_frame a bit. Patch by Vajrasky Kok. http://hg.python.org/cpython/rev/34e1ecb8edd2 ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 23:05:51 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Tue, 06 Aug 2013 21:05:51 +0000 Subject: [issue18666] Unused variable in test_frame.py In-Reply-To: <1375765297.44.0.682936392521.issue18666@psf.upfronthosting.co.za> Message-ID: <1375823151.59.0.977158471021.issue18666@psf.upfronthosting.co.za> Antoine Pitrou added the comment: Good idea, thank you! ---------- resolution: -> fixed stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 23:07:08 2013 From: report at bugs.python.org (Roundup Robot) Date: Tue, 06 Aug 2013 21:07:08 +0000 Subject: [issue18665] Typos in frame object related code In-Reply-To: <1375764800.58.0.482122024787.issue18665@psf.upfronthosting.co.za> Message-ID: <3c8pLz4dJjz7LkN@mail.python.org> Roundup Robot added the comment: New changeset 89ce323357db by Antoine Pitrou in branch 'default': Issue #18665: fix typos. Patch by Vajrasky Kok. http://hg.python.org/cpython/rev/89ce323357db ---------- nosy: +python-dev _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 23:07:33 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Tue, 06 Aug 2013 21:07:33 +0000 Subject: [issue18665] Typos in frame object related code In-Reply-To: <1375764800.58.0.482122024787.issue18665@psf.upfronthosting.co.za> Message-ID: <1375823253.21.0.0137643855807.issue18665@psf.upfronthosting.co.za> Antoine Pitrou added the comment: Thank you :) ---------- resolution: -> fixed stage: needs patch -> committed/rejected status: open -> closed versions: -Python 2.7, Python 3.3 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 23:09:04 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Tue, 06 Aug 2013 21:09:04 +0000 Subject: [issue8713] multiprocessing needs option to eschew fork() under Linux In-Reply-To: <1273853591.12.0.245920632829.issue8713@psf.upfronthosting.co.za> Message-ID: <1375823344.05.0.153253356884.issue8713@psf.upfronthosting.co.za> Changes by Antoine Pitrou : Added file: http://bugs.python.org/file31181/d9fe9757ba0c.diff _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 23:09:51 2013 From: report at bugs.python.org (Vinay Sajip) Date: Tue, 06 Aug 2013 21:09:51 +0000 Subject: [issue18671] enhance formatting in logging package In-Reply-To: <1375804669.84.0.0477385788117.issue18671@psf.upfronthosting.co.za> Message-ID: <1375823391.98.0.540489527162.issue18671@psf.upfronthosting.co.za> Vinay Sajip added the comment: In recent versions of Python, information *is* printed which allows pinpointing the source of the formatting error. Consider the following script, logex.py: import logging logger = logging.getLogger(__name__) def test(): logger.debug('The result is ', 'abc') def main(): test() if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG) main() When this is run with Python 2.7: $ python logex.py Traceback (most recent call last): File "/usr/lib/python2.7/logging/__init__.py", line 842, in emit msg = self.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 719, in format return fmt.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 464, in format record.message = record.getMessage() File "/usr/lib/python2.7/logging/__init__.py", line 328, in getMessage msg = msg % self.args TypeError: not all arguments converted during string formatting Logged from file logex.py, line 6 With Python 3.2: $ python3.2 logex.py Traceback (most recent call last): File "/usr/lib/python3.2/logging/__init__.py", line 937, in emit msg = self.format(record) File "/usr/lib/python3.2/logging/__init__.py", line 812, in format return fmt.format(record) File "/usr/lib/python3.2/logging/__init__.py", line 551, in format record.message = record.getMessage() File "/usr/lib/python3.2/logging/__init__.py", line 319, in getMessage msg = msg % self.args TypeError: not all arguments converted during string formatting Logged from file logex.py, line 6 As you can see, the filename and line number are identified, so you can see precisely where the formatting error is. ---------- components: +Library (Lib) -Extension Modules resolution: -> invalid status: open -> pending _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 23:11:19 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Tue, 06 Aug 2013 21:11:19 +0000 Subject: [issue18528] Possible fd leak in socketmodule In-Reply-To: <1374496496.68.0.51305379842.issue18528@psf.upfronthosting.co.za> Message-ID: <1375823479.77.0.716141730662.issue18528@psf.upfronthosting.co.za> Antoine Pitrou added the comment: > I don't understand why we would call accept() more than once. Because of EINTR? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 23:14:50 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Tue, 06 Aug 2013 21:14:50 +0000 Subject: [issue18673] Add and use O_TMPFILE for Linux 3.11 In-Reply-To: <1375818220.16.0.883591943761.issue18673@psf.upfronthosting.co.za> Message-ID: <1375823690.43.0.581466218305.issue18673@psf.upfronthosting.co.za> Antoine Pitrou added the comment: > - use O_TEMPFILE in tempfile module when it's supported by the current > kernel I assume this would only be done in TemporaryFile()? ---------- components: -Extension Modules keywords: +easy nosy: +pitrou _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 23:25:49 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Tue, 06 Aug 2013 21:25:49 +0000 Subject: [issue18290] json encoder does not support JSONP/JavaScript safe escaping In-Reply-To: <1372049179.79.0.237326954931.issue18290@psf.upfronthosting.co.za> Message-ID: <1375824349.62.0.711607520812.issue18290@psf.upfronthosting.co.za> Antoine Pitrou added the comment: On the one hand, supporting JSONP is a valid request for the json module. On the other hand, according to Wikipedia, "There have been some criticisms raised about JSONP. Cross-origin resource sharing (CORS) is a more recent method of getting data from a server in a different domain, which addresses some of those criticisms". Therefore, supporting JSONP might not really be worth it. ---------- status: pending -> open _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 23:26:01 2013 From: report at bugs.python.org (Eli Bendersky) Date: Tue, 06 Aug 2013 21:26:01 +0000 Subject: [issue15651] PEP 3121, 384 refactoring applied to elementtree module In-Reply-To: <1344968721.44.0.689766020196.issue15651@psf.upfronthosting.co.za> Message-ID: <1375824361.17.0.485098008305.issue15651@psf.upfronthosting.co.za> Eli Bendersky added the comment: Bless you Antoine, I've been just planning to do this myself to tackle the re-importing troubles I was having in tests the other day :-) I'll take a look at this soon, promise! ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 23:28:00 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Tue, 06 Aug 2013 21:28:00 +0000 Subject: [issue18659] test_precision in test_format.py is not executed and has unused variable In-Reply-To: <1375689790.25.0.721615428383.issue18659@psf.upfronthosting.co.za> Message-ID: <1375824480.26.0.152812348268.issue18659@psf.upfronthosting.co.za> Changes by Antoine Pitrou : ---------- nosy: +eric.smith _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 23:29:20 2013 From: report at bugs.python.org (Brett Cannon) Date: Tue, 06 Aug 2013 21:29:20 +0000 Subject: [issue18674] Store weak references in modules_by_index In-Reply-To: <1375821531.36.0.318072139637.issue18674@psf.upfronthosting.co.za> Message-ID: <1375824560.89.0.883299221181.issue18674@psf.upfronthosting.co.za> Brett Cannon added the comment: Won't that change to PyState_FindModule() break code? And is it part of the stable ABI? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 23:37:44 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Tue, 06 Aug 2013 21:37:44 +0000 Subject: [issue18674] Store weak references in modules_by_index In-Reply-To: <1375821531.36.0.318072139637.issue18674@psf.upfronthosting.co.za> Message-ID: <1375825064.19.0.13296104467.issue18674@psf.upfronthosting.co.za> Antoine Pitrou added the comment: Theoretically, people *should* already incref the result from PyState_FindModule. On the other hand, the object currently wouldn't be lost unless something else calls PyState_RemoveModule(), which is hardly every used AFAICT. The only saving grace is that PyState_FindModule() is py3-specific, and only used for extension modules which have a positive m_size (probably not many of them yet). (I think this issue teaches us that borrowed ref-returning APIs are a bad idea) Unfortunately, without this change, we also make it difficult or impossible to reclaim extension modules using the GC. At least I cannot think of another way. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 23:39:35 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Tue, 06 Aug 2013 21:39:35 +0000 Subject: [issue18667] missing HAVE_FCHOWNAT In-Reply-To: <1375772087.0.0.361755653525.issue18667@psf.upfronthosting.co.za> Message-ID: <1375825175.18.0.531357913407.issue18667@psf.upfronthosting.co.za> Changes by Antoine Pitrou : ---------- nosy: +larry _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 23:51:05 2013 From: report at bugs.python.org (Larry Hastings) Date: Tue, 06 Aug 2013 21:51:05 +0000 Subject: [issue18667] missing HAVE_FCHOWNAT In-Reply-To: <1375772087.0.0.361755653525.issue18667@psf.upfronthosting.co.za> Message-ID: <1375825865.26.0.650988208843.issue18667@psf.upfronthosting.co.za> Larry Hastings added the comment: Yup, that's a bug. My fault too. I think it should go in to the next 3.3 as well. I worry that this may be a similar situation to fchmodat--see the comment in Lib/os.py--but for now let's be brave and add HAVE_FCHOWNAT to have_functions as salinger suggests. ---------- versions: +Python 3.3 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Aug 6 23:53:58 2013 From: report at bugs.python.org (Terry J. Reedy) Date: Tue, 06 Aug 2013 21:53:58 +0000 Subject: [issue13153] IDLE crashes when pasting non-BMP unicode char on Py3 In-Reply-To: <1318363292.9.0.682519731008.issue13153@psf.upfronthosting.co.za> Message-ID: <1375826038.87.0.733196014777.issue13153@psf.upfronthosting.co.za> Terry J. Reedy added the comment: Byte 0, not byte 1, is the start byte, and it should be F0, as in output below. However, I now see "invalid continuation byte'. In 2.7.5, # -*- coding: utf-8 -*- s = b'?' # output same if uncomment following lines #s = u'?'.encode('utf-8') # '?' pasted in from 1st post #s = u'\U000104a2'.encode('utf-8') print(len(s)) for c in s: print(ord(c), hex(ord(c))) >>> 4 (240, '0xf0') (144, '0x90') (146, '0x92') (162, '0xa2') I have no idea how the second pasted byte becomes ED in 3.x. Attempting to open the file in 3.x results in a broken* 'Untitled' edit window and the following error message in the console. _tkinter.TclError: character U+104a2 is above the range (U+0000-U+FFFF) allowed by Tcl * Attempting to close the window either immediately or after entering text results in AttributeError: 'PyShellEditorWindow' object has no attribute 'extensions' I have to close the initial python process to get rid of it. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 00:04:17 2013 From: report at bugs.python.org (Brett Cannon) Date: Tue, 06 Aug 2013 22:04:17 +0000 Subject: [issue18674] Store weak references in modules_by_index In-Reply-To: <1375821531.36.0.318072139637.issue18674@psf.upfronthosting.co.za> Message-ID: <1375826657.4.0.964445766175.issue18674@psf.upfronthosting.co.za> Brett Cannon added the comment: Sounds like it needs to be changed with a notice in What's New. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 00:17:31 2013 From: report at bugs.python.org (Nick Coghlan) Date: Tue, 06 Aug 2013 22:17:31 +0000 Subject: [issue18416] Move to absolute file paths for module.__file__ In-Reply-To: <1375805266.28.0.128618982976.issue18416@psf.upfronthosting.co.za> Message-ID: Nick Coghlan added the comment: Make sure to run "make" to rebuild the frozen module - editing importlib._bootstrap.py involves a C style "edit, build, test" cycle rather than the typical Python "edit, test" cycle. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 01:00:48 2013 From: report at bugs.python.org (M. Dietrich) Date: Tue, 06 Aug 2013 23:00:48 +0000 Subject: [issue18671] enhance formatting in logging package In-Reply-To: <1375804669.84.0.0477385788117.issue18671@psf.upfronthosting.co.za> Message-ID: <1375830048.97.0.470234725831.issue18671@psf.upfronthosting.co.za> M. Dietrich added the comment: yes, seeing the erranous line where the wrong formatstring comes from is nice but sometimes (for myself: often) i need to know what actually was tried to be logged. this information is lost in both cases. this is especially sad if you have long-running processes that encounter an error after a long time and that error is logged but the logging itself fails due to formatting issues. i suggest to log whatever is avaiable in the suggested way to at least see this valuable information. the additional information where it comes from for further fixing is apreaciated as well. btw: the stackstrace of the logging internals could be left out in my oppinion, it just pollutes the output with no means to the programer. ---------- status: pending -> open _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 01:01:41 2013 From: report at bugs.python.org (Guido van Rossum) Date: Tue, 06 Aug 2013 23:01:41 +0000 Subject: [issue16853] add a Selector to the select module In-Reply-To: <1357234686.56.0.503079428281.issue16853@psf.upfronthosting.co.za> Message-ID: <1375830101.38.0.941243598386.issue16853@psf.upfronthosting.co.za> Guido van Rossum added the comment: Yeah, the timeouts are a bad idea anyway. I've filed http://code.google.com/p/tulip/issues/detail?id=49 to remind us to do something about this. I'll review your tulip patch next. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 01:16:21 2013 From: report at bugs.python.org (Madison May) Date: Tue, 06 Aug 2013 23:16:21 +0000 Subject: [issue18416] Move to absolute file paths for module.__file__ In-Reply-To: <1373400107.5.0.285657244525.issue18416@psf.upfronthosting.co.za> Message-ID: <1375830981.93.0.472397887688.issue18416@psf.upfronthosting.co.za> Madison May added the comment: Thanks for the heads up, Nick. I've worked with _bootstrap.py before, so I'm familiar with the cycle. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 01:33:16 2013 From: report at bugs.python.org (Guido van Rossum) Date: Tue, 06 Aug 2013 23:33:16 +0000 Subject: [issue16853] add a Selector to the select module In-Reply-To: <1357234686.56.0.503079428281.issue16853@psf.upfronthosting.co.za> Message-ID: <1375831996.78.0.842152197232.issue16853@psf.upfronthosting.co.za> Guido van Rossum added the comment: Actually there is a misunderstanding underlying you Tulip patch. Tulip needs to support Python 3.3 as well as Python 3.4, so it needs to do a little dance trying to import BaseSelector (or some other key class) from select and if that fails fall back to its own selectors.py. Since you aren't changing the BaseSelector API at all this is trivial and I can take care of it. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 01:55:39 2013 From: report at bugs.python.org (Guido van Rossum) Date: Tue, 06 Aug 2013 23:55:39 +0000 Subject: [issue16853] add a Selector to the select module In-Reply-To: <1375456613.31.0.987002581332.issue16853@psf.upfronthosting.co.za> Message-ID: Guido van Rossum added the comment: Sorry, replying to some direct questions in the bug: > I also made the following changes: > - BaseSelector is an abstract base class (so one could imagine user code > implementing its own selector on top of it) Fine (though I had to work around this for some tulip tests). > - SelectorKey is a named tuple: I think that's better than a class, > because SelectorKeys can be returned to the user (register(), get_info(), > etc), and we don't want him to mess with them. Also, we get a nice repr() > for free Fine. > - since SelectorKey is immutable, I added a get_keys() method, which > returns all the keys registered. Since it's a dict values, the user can't > mess with it Fine. (I missed this in the code review.) > This get_keys() method superseedes the registered_count() method, which > can be simply replaced with len(selector.get_keys()). We could probably > remove it? It also sort of superseedes the get_info() method: I don't > remember, why was it needed? registered_count() is only used internally so you can kill it. get_info() is important for Tulip, please keep it. > Would it be possible to get it into 3.4? I think so, if Antoine agrees. The next alpha would be at your service. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 02:01:36 2013 From: report at bugs.python.org (Vinay Sajip) Date: Wed, 07 Aug 2013 00:01:36 +0000 Subject: [issue18671] enhance formatting in logging package In-Reply-To: <1375804669.84.0.0477385788117.issue18671@psf.upfronthosting.co.za> Message-ID: <1375833696.81.0.20864048556.issue18671@psf.upfronthosting.co.za> Vinay Sajip added the comment: The location of the error isn't lost - that's the important thing. If it's that important that you never lose the parameters of a logging call, then you could just double check the formatting for errors, or use a specialised message object, as described in the documentation, which allows you control over the formatting: http://docs.python.org/2/howto/logging.html#using-arbitrary-objects-as-messages ---------- status: open -> pending _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 03:49:56 2013 From: report at bugs.python.org (Nick Coghlan) Date: Wed, 07 Aug 2013 01:49:56 +0000 Subject: [issue18674] Store weak references in modules_by_index In-Reply-To: <1375821531.36.0.318072139637.issue18674@psf.upfronthosting.co.za> Message-ID: <1375840196.98.0.117433808484.issue18674@psf.upfronthosting.co.za> Nick Coghlan added the comment: It seems to me that the more appropriate change here would be to redefine PyState_FindModule as return a *new* ref rather than a borrowed ref and have it do the Py_INCREF before returning. Code using it would then need to add an appropriate Py_DECREF. A reference leak is generally a less dangerous bug than an early free. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 06:58:41 2013 From: report at bugs.python.org (Nick Coghlan) Date: Wed, 07 Aug 2013 04:58:41 +0000 Subject: [issue18416] Move to absolute file paths for module.__file__ In-Reply-To: <1375830981.93.0.472397887688.issue18416@psf.upfronthosting.co.za> Message-ID: Nick Coghlan added the comment: Figured it was worth mentioning, since I've been caught by forgetting that myself :) I suspect you're right that it's just a case of '.' passing the truth test, even though it still results in a relative path. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 09:45:33 2013 From: report at bugs.python.org (Thomas Guettler) Date: Wed, 07 Aug 2013 07:45:33 +0000 Subject: [issue1596321] KeyError at exit after 'import threading' in other thread Message-ID: <1375861533.43.0.108147005605.issue1596321@psf.upfronthosting.co.za> Thomas Guettler added the comment: Only few people seem to use daemon threads. We do and see this problem often with Python 2.7. How difficult is it to get this fixed for 2.7? Is there a way to work around this problem? ---------- nosy: +guettli _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 10:02:30 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Wed, 07 Aug 2013 08:02:30 +0000 Subject: [issue18674] Store weak references in modules_by_index In-Reply-To: <1375840196.98.0.117433808484.issue18674@psf.upfronthosting.co.za> Message-ID: <1301002546.47906547.1375862544095.JavaMail.root@zimbra10-e2.priv.proxad.net> Antoine Pitrou added the comment: > It seems to me that the more appropriate change here would be to > redefine PyState_FindModule as return a *new* ref rather than a > borrowed ref and have it do the Py_INCREF before returning. > > Code using it would then need to add an appropriate Py_DECREF. A > reference leak is generally a less dangerous bug than an early free. I hadn't thought about that. Code must add Py_DECREF only on 3.4+, then. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 11:05:59 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Wed, 07 Aug 2013 09:05:59 +0000 Subject: [issue15787] PEP 3121 Refactoring In-Reply-To: <1346038565.61.0.980658052428.issue15787@psf.upfronthosting.co.za> Message-ID: <1375866359.53.0.345964230462.issue15787@psf.upfronthosting.co.za> Changes by Alexander Belopolsky : ---------- dependencies: +PEP 3121 Refactoring applied to _csv module _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 11:07:47 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Wed, 07 Aug 2013 09:07:47 +0000 Subject: [issue15787] PEP 3121 Refactoring In-Reply-To: <1346038565.61.0.980658052428.issue15787@psf.upfronthosting.co.za> Message-ID: <1375866467.15.0.33153472509.issue15787@psf.upfronthosting.co.za> Changes by Alexander Belopolsky : ---------- dependencies: +PEP 3121, 384 refactoring applied to curses_panel module _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 11:10:29 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Wed, 07 Aug 2013 09:10:29 +0000 Subject: [issue15787] PEP 3121, 384 Refactoring In-Reply-To: <1346038565.61.0.980658052428.issue15787@psf.upfronthosting.co.za> Message-ID: <1375866629.79.0.219476976872.issue15787@psf.upfronthosting.co.za> Changes by Alexander Belopolsky : ---------- dependencies: +PEP 384 Refactoring applied to _csv module title: PEP 3121 Refactoring -> PEP 3121, 384 Refactoring _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 11:13:37 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Wed, 07 Aug 2013 09:13:37 +0000 Subject: [issue15787] PEP 3121, 384 Refactoring In-Reply-To: <1346038565.61.0.980658052428.issue15787@psf.upfronthosting.co.za> Message-ID: <1375866817.75.0.994341809252.issue15787@psf.upfronthosting.co.za> Changes by Alexander Belopolsky : ---------- dependencies: +PEP 384 inconsistent with implementation _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 11:21:03 2013 From: report at bugs.python.org (Thomas Guettler) Date: Wed, 07 Aug 2013 09:21:03 +0000 Subject: [issue1856] shutdown (exit) can hang or segfault with daemon threads running In-Reply-To: <1200535276.53.0.276618350299.issue1856@psf.upfronthosting.co.za> Message-ID: <1375867263.71.0.814492313411.issue1856@psf.upfronthosting.co.za> Thomas Guettler added the comment: There are some examples to work around this for Python2: http://stackoverflow.com/questions/18098475/detect-interpreter-shut-down-in-daemon-thread ---------- nosy: +guettli _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 11:21:46 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Wed, 07 Aug 2013 09:21:46 +0000 Subject: [issue15787] PEP 3121, 384 Refactoring In-Reply-To: <1346038565.61.0.980658052428.issue15787@psf.upfronthosting.co.za> Message-ID: <1375867306.55.0.91837715789.issue15787@psf.upfronthosting.co.za> Alexander Belopolsky added the comment: """ Regarding the suggestion of separating PEP3121 and PEP384. It might be true that datetime and other modules do not benefit directly from PEP 384, however it is still a fact that the stdlib modules should be seen as a set of reference modules, that are all implemented in a way that complies with the implementation fo the xxmodules. I have talked with Martin von L?wis about this, and as far as I understood him correctly he also sees the PEP384 refactoring applied to the whole stdlib as a necessary "signal" to other developers to refactor their modules accordingly. """ (Robin Schreiber, #15390, msg177274) MvL have recently confirmed this on python-dev: "Choice of supporting PEP 384 was deliberate. It will change all types into heap types, which is useful for multiple-interpreter support and GC." Accordingly, I've changed the title of this issue and added a few PEP 384 only dependencies. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 11:23:16 2013 From: report at bugs.python.org (Thomas Guettler) Date: Wed, 07 Aug 2013 09:23:16 +0000 Subject: [issue18675] Daemon Threads can seg fault Message-ID: <1375867396.76.0.697227657582.issue18675@psf.upfronthosting.co.za> New submission from Thomas Guettler: This is a documentation bug: Since #1856 is not solved for Python2, it needs to be documented. Daemon Threads on Python2 can seg fault. Work arounds: http://stackoverflow.com/questions/18098475/detect-interpreter-shut-down-in-daemon-thread ---------- assignee: docs at python components: Documentation messages: 194601 nosy: docs at python, guettli priority: normal severity: normal status: open title: Daemon Threads can seg fault versions: Python 2.6, Python 2.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 11:23:36 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Wed, 07 Aug 2013 09:23:36 +0000 Subject: [issue15787] PEP 3121, 384 Refactoring In-Reply-To: <1346038565.61.0.980658052428.issue15787@psf.upfronthosting.co.za> Message-ID: <1375867416.48.0.219914104404.issue15787@psf.upfronthosting.co.za> Changes by Alexander Belopolsky : ---------- nosy: +pitrou _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 11:34:13 2013 From: report at bugs.python.org (Alexander Belopolsky) Date: Wed, 07 Aug 2013 09:34:13 +0000 Subject: [issue15787] PEP 3121, 384 Refactoring In-Reply-To: <1346038565.61.0.980658052428.issue15787@psf.upfronthosting.co.za> Message-ID: <1375868053.43.0.99191595519.issue15787@psf.upfronthosting.co.za> Alexander Belopolsky added the comment: With respect to PEP 384 refactoring, I would like to see Tools/scripts/abitype.py used for most of the conversions. The PEP itself can probably be amended to advertise this tool more prominently. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 12:01:05 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Wed, 07 Aug 2013 10:01:05 +0000 Subject: [issue13153] IDLE crashes when pasting non-BMP unicode char on Py3 In-Reply-To: <1318363292.9.0.682519731008.issue13153@psf.upfronthosting.co.za> Message-ID: <1375869665.56.0.425122885877.issue13153@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: u'\U000104a2' == u'\ud801\udca2' on narrow build. u'\ud801'.encode('utf-8', 'surrogatepass') == b'\xed\xa0\x81' u'\udca2'.encode('utf-8', 'surrogatepass') == b'\xed\xb2\xa2' Hope it will help. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 13:23:04 2013 From: report at bugs.python.org (M. Dietrich) Date: Wed, 07 Aug 2013 11:23:04 +0000 Subject: [issue18671] enhance formatting in logging package In-Reply-To: <1375804669.84.0.0477385788117.issue18671@psf.upfronthosting.co.za> Message-ID: <1375874584.95.0.381166066073.issue18671@psf.upfronthosting.co.za> M. Dietrich added the comment: for a logging library the important thing would be to not loose the information that was meant to log. as i said i do alot of long-running huge-data-processing scripts in py using the library. if the logging breaks but doesnt log what was intended to log i judge this a major problem. and furthermore: it is so simple to add both information: the data that was to be logged plus the state that an error occured while formatting and where the log-call was made. ---------- status: pending -> open _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 14:54:57 2013 From: report at bugs.python.org (Roundup Robot) Date: Wed, 07 Aug 2013 12:54:57 +0000 Subject: [issue18668] Properly document setting m_size in PyModuleDef In-Reply-To: <1375795246.61.0.949649493069.issue18668@psf.upfronthosting.co.za> Message-ID: <3c9CNc6Qf2z7Lm6@mail.python.org> Roundup Robot added the comment: New changeset 698fd628b001 by Eli Bendersky in branch '3.3': Issue #18668: Properly document setting m_size in PyModuleDef http://hg.python.org/cpython/rev/698fd628b001 New changeset 9877c25d9556 by Eli Bendersky in branch 'default': Closing #18668: Properly document setting m_size in PyModuleDef http://hg.python.org/cpython/rev/9877c25d9556 ---------- nosy: +python-dev resolution: -> fixed stage: needs patch -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 14:55:25 2013 From: report at bugs.python.org (Eli Bendersky) Date: Wed, 07 Aug 2013 12:55:25 +0000 Subject: [issue18668] Properly document setting m_size in PyModuleDef In-Reply-To: <1375795246.61.0.949649493069.issue18668@psf.upfronthosting.co.za> Message-ID: <1375880125.87.0.432442027172.issue18668@psf.upfronthosting.co.za> Eli Bendersky added the comment: Thanks for the review! ---------- resolution: fixed -> stage: committed/rejected -> needs patch status: closed -> open _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 14:55:54 2013 From: report at bugs.python.org (Eli Bendersky) Date: Wed, 07 Aug 2013 12:55:54 +0000 Subject: [issue18668] Properly document setting m_size in PyModuleDef In-Reply-To: <1375795246.61.0.949649493069.issue18668@psf.upfronthosting.co.za> Message-ID: <1375880154.4.0.271359421302.issue18668@psf.upfronthosting.co.za> Changes by Eli Bendersky : ---------- resolution: -> fixed stage: needs patch -> committed/rejected status: open -> closed _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 15:11:17 2013 From: report at bugs.python.org (Eli Bendersky) Date: Wed, 07 Aug 2013 13:11:17 +0000 Subject: [issue15651] PEP 3121, 384 refactoring applied to elementtree module In-Reply-To: <1344968721.44.0.689766020196.issue15651@psf.upfronthosting.co.za> Message-ID: <1375881077.68.0.595566651837.issue15651@psf.upfronthosting.co.za> Eli Bendersky added the comment: Antoine, some questions about the patch: First, I think it omits expat_capi from the state. Is that intentional? Second, I'm not sure if this approach is fully aligned with PEP 3121. A global, shared state is still used. Instead of actually having a different module state per subinterpreter, this patch will have shared state. Another problem seems to be using PyModule_FindModule without using PyModule_AddModule first. These problems could be shared to all of Robin's original patches. Of course, there's also the possibility that I don't fully understand PEP 3121 yet :) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 15:28:36 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Wed, 07 Aug 2013 13:28:36 +0000 Subject: [issue15651] PEP 3121, 384 refactoring applied to elementtree module In-Reply-To: <1375881077.68.0.595566651837.issue15651@psf.upfronthosting.co.za> Message-ID: <1404971900.48608507.1375882110112.JavaMail.root@zimbra10-e2.priv.proxad.net> Antoine Pitrou added the comment: > First, I think it omits expat_capi from the state. Is that > intentional? What would it do in the state? There's nothing to release. > Second, I'm not sure if this approach is fully aligned with PEP 3121. > A global, shared state is still used. Instead of actually having a > different module state per subinterpreter, this patch will have > shared state. I don't understand what you are talking about. Perhaps you haven't looked what PyState_FindModule() does? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 15:32:30 2013 From: report at bugs.python.org (Nick Coghlan) Date: Wed, 07 Aug 2013 13:32:30 +0000 Subject: [issue18668] Properly document setting m_size in PyModuleDef In-Reply-To: <1375880154.43.0.901535903334.issue18668@psf.upfronthosting.co.za> Message-ID: Nick Coghlan added the comment: I thought setting m_size to zero was for "No per module state, but reinitialization is fine"? Does that not work? (I haven't actually tried it) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 15:47:16 2013 From: report at bugs.python.org (Eli Bendersky) Date: Wed, 07 Aug 2013 13:47:16 +0000 Subject: [issue15651] PEP 3121, 384 refactoring applied to elementtree module In-Reply-To: <1404971900.48608507.1375882110112.JavaMail.root@zimbra10-e2.priv.proxad.net> Message-ID: Eli Bendersky added the comment: On Wed, Aug 7, 2013 at 6:28 AM, Antoine Pitrou wrote: > > Antoine Pitrou added the comment: > > > First, I think it omits expat_capi from the state. Is that > > intentional? > > What would it do in the state? There's nothing to release. > That's true, but I thought one of the goals of PEP 3121 is to separate states between sub-interpreters. So that one can't corrupt another. I'm not sure how much it matters in practice in this case of the pyexpat capsule; need to look into it more. > > Second, I'm not sure if this approach is fully aligned with PEP 3121. > > A global, shared state is still used. Instead of actually having a > > different module state per subinterpreter, this patch will have > > shared state. > > I don't understand what you are talking about. Perhaps you haven't looked > what PyState_FindModule() does? > I did not look at the implementation yet. But the documentation says: """Returns the module object that was created from *def* for the current interpreter. This method requires that the module object has been attached to the interpreter state with PyState_AddModule()beforehand. In case the corresponding module object is not found or has not been attached to the interpreter state yet, it returns NULL.""" I don't see a call to PyState_AddModule. What am I missing? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 15:52:08 2013 From: report at bugs.python.org (Zhongyue Luo) Date: Wed, 07 Aug 2013 13:52:08 +0000 Subject: [issue18676] Queue: zero should not be accepted as timeout value Message-ID: <1375883528.55.0.275850242187.issue18676@psf.upfronthosting.co.za> New submission from Zhongyue Luo: The docstring of methods put() and get() in Queue.py states get(): If 'timeout' is a positive number, it blocks at most 'timeout' seconds and raises the Full exception if no free slot was available within that time. put(): If 'timeout' is a positive number, it blocks at most 'timeout' seconds and raises the Empty exception if no item was available within that time. Additionally the ValueError both methods raise is raise ValueError("'timeout' must be a positive number") However the logic checks if 'timeout' is non-negative. elif timeout < 0: raise ValueError("'timeout' must be a positive number") The logic should change as elif timeout <= 0: raise ValueError("'timeout' must be a positive number") ---------- components: Library (Lib) messages: 194611 nosy: zyluo priority: normal severity: normal status: open title: Queue: zero should not be accepted as timeout value type: behavior versions: Python 2.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 16:00:07 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Wed, 07 Aug 2013 14:00:07 +0000 Subject: [issue15651] PEP 3121, 384 refactoring applied to elementtree module In-Reply-To: Message-ID: <1399729306.48655520.1375884001005.JavaMail.root@zimbra10-e2.priv.proxad.net> Antoine Pitrou added the comment: > That's true, but I thought one of the goals of PEP 3121 is to > separate > states between sub-interpreters. So that one can't corrupt another. > I'm not > sure how much it matters in practice in this case of the pyexpat > capsule; > need to look into it more. pyexpat's "capi" object is a static struct inside pyexpat.c, so that wouldn't change anything. Separating states between sub-interpreters only matters when said state is mutable, which it isn't here. > I don't see a call to PyState_AddModule. What am I missing? It is called implicitly when an extension module is imported. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 16:11:40 2013 From: report at bugs.python.org (R. David Murray) Date: Wed, 07 Aug 2013 14:11:40 +0000 Subject: [issue18676] Queue: document that zero is accepted as timeout value In-Reply-To: <1375883528.55.0.275850242187.issue18676@psf.upfronthosting.co.za> Message-ID: <1375884700.35.0.298090985729.issue18676@psf.upfronthosting.co.za> R. David Murray added the comment: This is more of a documentation issue than a code issue. To be mathematically precise, the text and error message should read "a non-negative value". Alternatively the text and error could be changed to report that timeout may not be negative, which would probably be clearer. (Note that timeout is a float value, and thus the proposed code change would only break code, it would not change the functionality in any significant way.) ---------- assignee: -> docs at python components: +Documentation nosy: +docs at python, r.david.murray title: Queue: zero should not be accepted as timeout value -> Queue: document that zero is accepted as timeout value versions: +Python 3.3, Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 16:15:20 2013 From: report at bugs.python.org (Vinay Sajip) Date: Wed, 07 Aug 2013 14:15:20 +0000 Subject: [issue18671] enhance formatting in logging package In-Reply-To: <1375804669.84.0.0477385788117.issue18671@psf.upfronthosting.co.za> Message-ID: <1375884920.64.0.433087813368.issue18671@psf.upfronthosting.co.za> Vinay Sajip added the comment: >From the line number you mentioned, it looks like you're talking about Python 2.7. However, Python 2.7 is closed to new features: generally speaking, only bug fixes are supposed to be committed to this branch. I can consider expanding the "Logged from ..." error message for 3.4. ---------- resolution: invalid -> status: open -> pending versions: +Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 16:22:07 2013 From: report at bugs.python.org (=?utf-8?q?Kristj=C3=A1n_Valur_J=C3=B3nsson?=) Date: Wed, 07 Aug 2013 14:22:07 +0000 Subject: [issue18677] Enhanced context managers with ContextManagerExit and None Message-ID: <1375885327.18.0.790620363467.issue18677@psf.upfronthosting.co.za> New submission from Kristj?n Valur J?nsson: A proposed patch adds two features to context managers: 1)It has always irked me that it was impossible to assemble nested context managers in the python language. See issue #5251. The main problem, that exceptions in __enter__ cannot be properly handled, is fixed by introducing a new core exception, ContextManagerExit. When raised by __enter__(), the body that the context manager protects is skipped. This exception is in the spirit of other semi-internal exceptions such as GeneratorExit and StopIteration. Using this exception, contextlib.nested can properly handle the case where the body isn't run because of an internal __enter__ exception which is handled by an outer __exit__. 2) The mechanism used in implementing ContextManagerExit above is easily extended to allowing a special context manager: None. This is useful for having _optional_ context managers. E.g. code like this: with performance_timer(): do_work() def performance_timer(): if profiling: return accumulator return None None becomes the trivial context manager and its __enter__ and __exit__ calls are skipped, along with their overhead. This patch implements both features. In addition, it: 1) reintroduces contextlib.nested, which is based on nested_delayed 2) introduces contextlib.nested_delayed, which solves the other problem with previous versions of nested, that an inner context manager expression shouldn't be evaluated early. contextlib.nested evaluates callables returning context managers, rather than managers directly. 3) Allows contextlib.contextmanager decorated functions to not yield, which amounts to skipping the protected body (implicitly raising ContextManagerExit) 4) unittests for the whole thing. I'll introduce this stuff on python-ideas as well. ---------- components: Interpreter Core files: contextmanagerexit.patch keywords: patch messages: 194615 nosy: kristjan.jonsson priority: normal severity: normal status: open title: Enhanced context managers with ContextManagerExit and None type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file31182/contextmanagerexit.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 16:29:53 2013 From: report at bugs.python.org (Steven Velez) Date: Wed, 07 Aug 2013 14:29:53 +0000 Subject: [issue11619] On Windows, don't encode filenames in the import machinery In-Reply-To: <1300665531.85.0.426527059221.issue11619@psf.upfronthosting.co.za> Message-ID: <1375885793.55.0.619946041492.issue11619@psf.upfronthosting.co.za> Steven Velez added the comment: This may be a small use case, but a use case none-the less. In my situation, I am distributing a frozen python package and it runs under the users home directory. If the user's name has international characters, this will fail. I expect we will have similar problems when dealing with our application which embeds python and is also running from within the user directory... ---------- nosy: +Steven.Velez _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 16:44:39 2013 From: report at bugs.python.org (R. David Murray) Date: Wed, 07 Aug 2013 14:44:39 +0000 Subject: [issue18677] Enhanced context managers with ContextManagerExit and None In-Reply-To: <1375885327.18.0.790620363467.issue18677@psf.upfronthosting.co.za> Message-ID: <1375886679.42.0.377205129998.issue18677@psf.upfronthosting.co.za> R. David Murray added the comment: Your use cases are either already addressed by contextlib.ExitStack, or should be addressed in the context of its existence. It is the replacement for contextlib.nested. ---------- nosy: +ncoghlan, r.david.murray _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 16:50:00 2013 From: report at bugs.python.org (Vajrasky Kok) Date: Wed, 07 Aug 2013 14:50:00 +0000 Subject: [issue18678] Wrong struct members name for spwd module Message-ID: <1375887000.77.0.620898445025.issue18678@psf.upfronthosting.co.za> New submission from Vajrasky Kok: Both python2 and python3 have this behaviour. >>> import os; os.getuid() 0 >>> 'I am root' 'I am root' >>> import spwd >>> spwd.getspnam('bin') spwd.struct_spwd(sp_nam='bin', sp_pwd='*', sp_lstchg=15558, sp_min=0, sp_max=99999, sp_warn=7, sp_inact=-1, sp_expire=-1, sp_flag=-1) >>> spwd.getspnam.__doc__ 'getspnam(name) -> (sp_namp, sp_pwdp, sp_lstchg, sp_min, sp_max,\n sp_warn, sp_inact, sp_expire, sp_flag)\nReturn the shadow password database entry for the given user name.\nSee spwd.__doc__ for more on shadow password database entries.' The documentation tells the function getspnam will give struct which has member sp_namp and sp_pwdp. But as you can see, the function getspnam gives me a tuple with has member sp_nam (without p) and sp_pwd (without p). If you "man spwd", you can see the documentation is correct: Structure The shadow password structure is defined in as follows: struct spwd { char *sp_namp; /* Login name */ char *sp_pwdp; /* Encrypted password */ long sp_lstchg; /* Date of last change (measured in days since 1970-01-01 00:00:00 +0000 (UTC)) */ long sp_min; /* Min # of days between changes */ long sp_max; /* Max # of days between changes */ long sp_warn; /* # of days before password expires to warn user to change it */ long sp_inact; /* # of days after password expires until account is disabled */ long sp_expire; /* Date when account expires (measured in days since 1970-01-01 00:00:00 +0000 (UTC)) */ unsigned long sp_flag; /* Reserved */ }; For curious souls who do not have unix box: http://linux.die.net/man/3/getspnam I have contemplated about whether this behaviour is intended as it is, but I guess this is just a bug. Typo. Attached the patch to fix this inconsistency. I also fixed some documentation about sp_inact and sp_expire. I only marked this as Python 3.4 fix because I am not sure whether we should backport it to previous python versions. Some programs that expect sp_nam and sp_pwd names could break. ---------- components: Extension Modules files: spwd_struct_members_name_fix.patch keywords: patch messages: 194618 nosy: vajrasky priority: normal severity: normal status: open title: Wrong struct members name for spwd module type: behavior versions: Python 3.4 Added file: http://bugs.python.org/file31183/spwd_struct_members_name_fix.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 16:58:29 2013 From: report at bugs.python.org (R. David Murray) Date: Wed, 07 Aug 2013 14:58:29 +0000 Subject: [issue18678] Wrong struct members name for spwd module In-Reply-To: <1375887000.77.0.620898445025.issue18678@psf.upfronthosting.co.za> Message-ID: <1375887509.47.0.0976413745634.issue18678@psf.upfronthosting.co.za> R. David Murray added the comment: Ideally, for backward compatibility reasons we really ought to support access by the old (incorrect) name even in 3.4 (with a deprecation warning, even more ideally). I'm not sure if that's practical? ---------- nosy: +r.david.murray _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 16:59:58 2013 From: report at bugs.python.org (=?utf-8?q?Kristj=C3=A1n_Valur_J=C3=B3nsson?=) Date: Wed, 07 Aug 2013 14:59:58 +0000 Subject: [issue18677] Enhanced context managers with ContextManagerExit and None In-Reply-To: <1375885327.18.0.790620363467.issue18677@psf.upfronthosting.co.za> Message-ID: <1375887598.35.0.27585960555.issue18677@psf.upfronthosting.co.za> Kristj?n Valur J?nsson added the comment: IMHO, exitstack is not a very nice construct. It's implementation is far longer than contextlib.nested. And the chief problem still remains, which has not been addressed until this patch (as far as I know): In Python, it is impossible to combine existing context managers into a nested one. ExitStack may address a use case of nested context managers, but it doesn't address the basic problem. ContextManagerExit comes with its own nice little features, too. Now you can write: @contextlib.contextmanager: def if_ctxt(condition): if condition: yield #hey look! an if statement as a with statement! with if_ctxt(condition): do_work This can easily be extended, where a context manager can both manage context, _and_ provide optional execution of its block. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 17:04:51 2013 From: report at bugs.python.org (R. David Murray) Date: Wed, 07 Aug 2013 15:04:51 +0000 Subject: [issue18677] Enhanced context managers with ContextManagerExit and None In-Reply-To: <1375885327.18.0.790620363467.issue18677@psf.upfronthosting.co.za> Message-ID: <1375887891.87.0.521138189849.issue18677@psf.upfronthosting.co.za> R. David Murray added the comment: Raising it on python-ideas sounds like a good idea, then. I must admit that I don't understand what you mean by "combining existing context managers into a nested one" that isn't addressed by ExitStack. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 17:14:25 2013 From: report at bugs.python.org (Eric Snow) Date: Wed, 07 Aug 2013 15:14:25 +0000 Subject: [issue11619] On Windows, don't encode filenames in the import machinery In-Reply-To: <1300665531.85.0.426527059221.issue11619@psf.upfronthosting.co.za> Message-ID: <1375888465.16.0.345538827607.issue11619@psf.upfronthosting.co.za> Changes by Eric Snow : ---------- nosy: +eric.snow _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 18:29:21 2013 From: report at bugs.python.org (=?utf-8?q?Kristj=C3=A1n_Valur_J=C3=B3nsson?=) Date: Wed, 07 Aug 2013 16:29:21 +0000 Subject: [issue18677] Enhanced context managers with ContextManagerExit and None In-Reply-To: <1375885327.18.0.790620363467.issue18677@psf.upfronthosting.co.za> Message-ID: <1375892961.09.0.359583243118.issue18677@psf.upfronthosting.co.za> Kristj?n Valur J?nsson added the comment: Simply put, there is no way in the language to nest two context managers, even though we have full access to their implementation model, i.e. can call __enter__ and __exit__ manually. This reflects badly (pun intended) on Python's reflection and introspection capabilities. If context managers are to be first class entities in the language, then you ought to be able to write absract code using them, and assemble complex ones out of simple ones. Hypothetical code here: def nest(a, b): # currently not possible return c def run_with_context(ctxt, callable): # abstract executor with ctxt: return callable() run_with_context(nested(a,b), callable) ExitStack address one use case that contextlib.nested was supposed to solve, namely the cleanup of a dynamic sequence of context managers. But it does this no by creating a new manager, but by providing a programming pattern to follow. In that sensse, the multiple context manager syntax (with (a, b, c): ) is also a hack because it provides language magic to perform what you ought to be able to do dynamically... Does this makes sense? Anyway, by providing the ContextManagerExit exception, then sufficient flexibility is added to the context manager mechanism that at least the use case of nested() becomes possible. Context managers are really interesting things. I was inspired by Raymond Hettinger's talk last pycon to explore their capabilities and this is one of the things I came up with :) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 19:47:38 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Wed, 07 Aug 2013 17:47:38 +0000 Subject: [issue13153] IDLE crashes when pasting non-BMP unicode char on Py3 In-Reply-To: <1318363292.9.0.682519731008.issue13153@psf.upfronthosting.co.za> Message-ID: <1375897658.96.0.957123107415.issue13153@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: Seems as Tk stores pasted "\U000104a2" as surrogate pair "\ud801\udca2". Then it encoded in UTF-8 as "\xed\xa0\x81\xed\xb2\xa2" end passed to Python. Python converts char* to Unicode object with PyUnicode_FromString() which forbids invalid UTF-8 including encoded surrogates. Please test proposed patch on Windows. ---------- Added file: http://bugs.python.org/file31184/tkinter_string_conv.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 20:10:34 2013 From: report at bugs.python.org (Antoine Pitrou) Date: Wed, 07 Aug 2013 18:10:34 +0000 Subject: [issue18674] Store weak references in modules_by_index In-Reply-To: <1375821531.36.0.318072139637.issue18674@psf.upfronthosting.co.za> Message-ID: <1375899034.11.0.843897991988.issue18674@psf.upfronthosting.co.za> Antoine Pitrou added the comment: (and of course, with module states not being PyObjects, we have the same lifetimes issues as with Py_buffers not being PyObjects....) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 21:47:00 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Wed, 07 Aug 2013 19:47:00 +0000 Subject: [issue13153] IDLE crashes when pasting non-BMP unicode char on Py3 In-Reply-To: <1318363292.9.0.682519731008.issue13153@psf.upfronthosting.co.za> Message-ID: <1375904820.74.0.886959806383.issue13153@psf.upfronthosting.co.za> Changes by Serhiy Storchaka : Removed file: http://bugs.python.org/file31184/tkinter_string_conv.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 21:48:49 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Wed, 07 Aug 2013 19:48:49 +0000 Subject: [issue13153] IDLE crashes when pasting non-BMP unicode char on Py3 In-Reply-To: <1318363292.9.0.682519731008.issue13153@psf.upfronthosting.co.za> Message-ID: <1375904929.77.0.173582140422.issue13153@psf.upfronthosting.co.za> Changes by Serhiy Storchaka : Added file: http://bugs.python.org/file31185/tkinter_string_conv.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 23:22:45 2013 From: report at bugs.python.org (Derek Wilson) Date: Wed, 07 Aug 2013 21:22:45 +0000 Subject: [issue18679] include a codec to handle escaping only control characters but not any others Message-ID: <1375910565.85.0.834240880509.issue18679@psf.upfronthosting.co.za> New submission from Derek Wilson: Escaping strings for serialization or display is a common problem. Currently, in python3, in order to escape a sting, you need to do this: 'my\tstring'.encode('unicode_escape').decode('ascii') This would give you a string that was represented like this: 'my\\tstring' But this does not present a suitable representation when the string contains unicode characters. Consider this example: s = '?\t?' There is no method to write this string this with only the control character escaped. Even python itself recognizes this as a problem and implemented a "solution" for it. >>> s = '?\t?' >>> print(s) ? ? >>> print(repr(s)) '?\t?' >>> print(s.encode('unicode_escape').decode('ascii')) \u0391\t\u03a9 What I want is public exposure of the functionality to represent control characters with their common \ escape sequences (or \x## for control characters where necessary - for instance unit and record separators). I have numerous use cases for this and python's own str.__repr__ implementation shows that the functionality is valuable. I would bet that the majority of cases where people use unicode_escape something like a control_escape is more along the lines of what is desired. And while we're at it, it would be great if this were a unicode->unicode codec like the rot_13 codec. My desired soluiton would look like this: >>> import codecs >>> s = '?\t?' >>> e = codecs.encode(s, 'control_escape')) >>> print(e) ?\t? >>> print(codecs.decode(e, 'control_escape')) ? ? If this is something that could be included in python 3.4, that would be awesome. I am willing to work on this if so. ---------- components: Library (Lib) messages: 194625 nosy: underrun priority: normal severity: normal status: open title: include a codec to handle escaping only control characters but not any others type: enhancement versions: Python 3.4 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 23:47:28 2013 From: report at bugs.python.org (Zhongyue Luo) Date: Wed, 07 Aug 2013 21:47:28 +0000 Subject: [issue18676] Queue: document that zero is accepted as timeout value In-Reply-To: <1375883528.55.0.275850242187.issue18676@psf.upfronthosting.co.za> Message-ID: <1375912048.13.0.872004246723.issue18676@psf.upfronthosting.co.za> Zhongyue Luo added the comment: David, How about like below? elif timeout < sys.float_info.epsilon: raise ValueError("'timeout' must be a positive number") The docstring has been there for quite a while and IMHO it just doesn't make sense passing 0.0 as a timeout value. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 23:49:16 2013 From: report at bugs.python.org (Richard Oudkerk) Date: Wed, 07 Aug 2013 21:49:16 +0000 Subject: [issue8713] multiprocessing needs option to eschew fork() under Linux In-Reply-To: <1273853591.12.0.245920632829.issue8713@psf.upfronthosting.co.za> Message-ID: <1375912156.21.0.457962094734.issue8713@psf.upfronthosting.co.za> Changes by Richard Oudkerk : Added file: http://bugs.python.org/file31186/b3620777f54c.diff _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Aug 7 23:57:37 2013 From: report at bugs.python.org (Richard Oudkerk) Date: Wed, 07 Aug 2013 21:57:37 +0000 Subject: [issue8713] multiprocessing needs option to eschew fork() under Linux In-Reply-To: <1273853591.12.0.245920632829.issue8713@psf.upfronthosting.co.za> Message-ID: <1375912657.07.0.20879988651.issue8713@psf.upfronthosting.co.za> Richard Oudkerk added the comment: I have done quite a bit of refactoring and added some extra tests. When I try using the forkserver start method on the OSX Tiger buildbot (the only OSX one available) I get errors. I have disabled the tests for OSX, but it seemed to be working before. Maybe that was with a different buildbot. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 00:06:31 2013 From: report at bugs.python.org (Corey Farwell) Date: Wed, 07 Aug 2013 22:06:31 +0000 Subject: [issue18680] JSONDecoder should document that it raises a ValueError for malformed data Message-ID: <1375913191.45.0.0174536581066.issue18680@psf.upfronthosting.co.za> New submission from Corey Farwell: Before someone comes in and tries to correct me, I know Python documentation is different than Javadocs. It is common to test if the JSON is malformed using a try...catch. What if I want to catch something more specific than Exception? The only way a user would know what to catch is to `python -c "import json; json.loads('FAIL')"`. Many other Python modules document which exception is raised on invalid input/parameters. ---------- assignee: docs at python components: Documentation messages: 194628 nosy: corey, docs at python priority: normal severity: normal status: open title: JSONDecoder should document that it raises a ValueError for malformed data type: enhancement versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 00:13:09 2013 From: report at bugs.python.org (Corey Farwell) Date: Wed, 07 Aug 2013 22:13:09 +0000 Subject: [issue18680] JSONDecoder should document that it raises a ValueError for malformed data In-Reply-To: <1375913191.45.0.0174536581066.issue18680@psf.upfronthosting.co.za> Message-ID: <1375913589.04.0.736260704416.issue18680@psf.upfronthosting.co.za> Corey Farwell added the comment: Ideally, this would also be decoumented in json.loads/json.load ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 00:13:41 2013 From: report at bugs.python.org (Richard Oudkerk) Date: Wed, 07 Aug 2013 22:13:41 +0000 Subject: [issue18676] Queue: document that zero is accepted as timeout value In-Reply-To: <1375883528.55.0.275850242187.issue18676@psf.upfronthosting.co.za> Message-ID: <1375913621.79.0.342753932092.issue18676@psf.upfronthosting.co.za> Richard Oudkerk added the comment: > IMHO it just doesn't make sense passing 0.0 as a timeout value. I have written lots of code that looks like timeout = max(deadline - time.time(), 0) some_function(..., timeout=timeout) This makes perfect sense. Working code should not be broken -- it is the docsting that should be changed. I can't think of *any* function taking a timeout which rejects a zero timeout. See select(), poll(), Condition.wait(), Lock.acquire(), Thread.join(). In each case a zero timeout causes a non-blocking call. Also, note that the implementation does not contradict the docstring or documentation: they say nothing about what happens it timeout is zero (or negative). ---------- nosy: +sbt _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 00:15:33 2013 From: report at bugs.python.org (R. David Murray) Date: Wed, 07 Aug 2013 22:15:33 +0000 Subject: [issue18676] Queue: document that zero is accepted as timeout value In-Reply-To: <1375883528.55.0.275850242187.issue18676@psf.upfronthosting.co.za> Message-ID: <1375913733.6.0.703561629116.issue18676@psf.upfronthosting.co.za> R. David Murray added the comment: Exactly. 0 means "Don't wait, just raise an error immediately if the queue is empty/full". ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 00:18:32 2013 From: report at bugs.python.org (R. David Murray) Date: Wed, 07 Aug 2013 22:18:32 +0000 Subject: [issue18679] include a codec to handle escaping only control characters but not any others In-Reply-To: <1375910565.85.0.834240880509.issue18679@psf.upfronthosting.co.za> Message-ID: <1375913912.08.0.0922584482564.issue18679@psf.upfronthosting.co.za> R. David Murray added the comment: In what way does repr(x)[1:-1] not serve your use case? ---------- nosy: +r.david.murray _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 01:04:13 2013 From: report at bugs.python.org (M. Dietrich) Date: Wed, 07 Aug 2013 23:04:13 +0000 Subject: [issue18671] enhance formatting in logging package In-Reply-To: <1375804669.84.0.0477385788117.issue18671@psf.upfronthosting.co.za> Message-ID: <1375916653.17.0.528311517427.issue18671@psf.upfronthosting.co.za> M. Dietrich added the comment: thanks, it will be really helpful for me to have this fixed. as i consider this a "bug" it would be possible to "fix" this for 2.7 and yes you are right, i talked about 2.7 as we are still using this version in production. ---------- status: pending -> open _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 01:18:51 2013 From: report at bugs.python.org (Vinay Sajip) Date: Wed, 07 Aug 2013 23:18:51 +0000 Subject: [issue18671] enhance formatting in logging package In-Reply-To: <1375804669.84.0.0477385788117.issue18671@psf.upfronthosting.co.za> Message-ID: <1375917531.26.0.586546124677.issue18671@psf.upfronthosting.co.za> Vinay Sajip added the comment: Sorry, not for 2.7 - it's not a bug. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 01:36:54 2013 From: report at bugs.python.org (Nick Coghlan) Date: Wed, 07 Aug 2013 23:36:54 +0000 Subject: [issue18677] Enhanced context managers with ContextManagerExit and None In-Reply-To: <1375892961.09.0.359583243118.issue18677@psf.upfronthosting.co.za> Message-ID: Nick Coghlan added the comment: I pitched the idea of making it possible to skip the with statement body quite some time ago, and Guido convinced me it was a bad idea for much the same reason he chose PEP 343 over his original PEP 340 design: allowing suppression of exceptions from __enter__ hides local control flow by blurring the boundaries between with and if statements. Regarding nested, we killed that because it was a bug magnet for context managers that acquire the resource in __init__ (like file objects), not because it didn't work. It's trivial to recreate that API on top of ExitStack if you like it, though. The only thing that doesn't work (relative to actual nested with statements) is suppressing exceptions raised inside __enter__ methods. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 02:09:59 2013 From: report at bugs.python.org (=?utf-8?q?Kristj=C3=A1n_Valur_J=C3=B3nsson?=) Date: Thu, 08 Aug 2013 00:09:59 +0000 Subject: [issue18677] Enhanced context managers with ContextManagerExit and None In-Reply-To: <1375885327.18.0.790620363467.issue18677@psf.upfronthosting.co.za> Message-ID: <1375920599.21.0.7751913241.issue18677@psf.upfronthosting.co.za> Kristj?n Valur J?nsson added the comment: Hi there. "allowing suppression of exceptions from __enter__ hides local control flow by blurring the boundaries between with and if statements. " I'm not sure what this means. To me, it is a serious language design flaw that you can write a context manager, and it has a well known interface that you can invoke manually, but that you cannot take two existing context managers and assemble them into a nested one, correctly, however much you wiggle. In my mind, allowing context managers to skip the managed body breaks new ground. Both, by allowing this "combination" to be possible. And also by opening up new and exciting applications for context managers. If you saw Raymond's talk last Pycon, you should feel inspired to do new and exciting things with them. the bug-magnet you speak of I already addressed in my patch with nested-delayed, more as a measure of completeness (address both the problems that old "nested" had. The more serious bug (IMHO) is the suppression of __enter__ exceptions. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 03:16:49 2013 From: report at bugs.python.org (Madison May) Date: Thu, 08 Aug 2013 01:16:49 +0000 Subject: [issue18416] Move to absolute file paths for module.__file__ In-Reply-To: <1373400107.5.0.285657244525.issue18416@psf.upfronthosting.co.za> Message-ID: <1375924609.56.0.898504712178.issue18416@psf.upfronthosting.co.za> Madison May added the comment: Nick, it was definitely a good thing to mention. I had to learn the "edit, build, test" cycle the hard way my first time. It took me a good 15-20 minutes to figure out why none of my edits seemed to change anything :) Anyhow, here's how I see the issue. It seems like we have three main options: In option one, we only modify PathFinder._path_importer_cache(). if path == '': - path = '.' + path = _os.getcwd() This associates the cwd with FileFinder(cwd) in sys.path_importer_cache In option two, we only modify FileFinder.__init__(). - self.path = path or '.' + if not path or path == '.': + path = _os.getcwd() + self.path = path This associates '.' with FileFinder(cwd) in sys.path_importer_cache. In option three, we modify both PathFinder and FileFinder. In PathFinder._path_importer_cache() we remove the line that reassigns path to '.' if path is the empty string. - if path == '': - path = '.' In FileFinder.__init__(), we set path to _os.getcwd() if path is false. - self.path = path or '.' + self.path = path or _os.getcwd() This associates the empty string with FileFinder(cwd) in sys.path_importer_cache. What are your thoughts? Which solution would you all support? ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 03:22:25 2013 From: report at bugs.python.org (Zhongyue Luo) Date: Thu, 08 Aug 2013 01:22:25 +0000 Subject: [issue18676] Queue: document that zero is accepted as timeout value In-Reply-To: <1375883528.55.0.275850242187.issue18676@psf.upfronthosting.co.za> Message-ID: <1375924945.34.0.626694555382.issue18676@psf.upfronthosting.co.za> Changes by Zhongyue Luo : ---------- keywords: +patch Added file: http://bugs.python.org/file31187/queue_timeout_docstring.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 03:45:01 2013 From: report at bugs.python.org (Zhongyue Luo) Date: Thu, 08 Aug 2013 01:45:01 +0000 Subject: [issue18676] Queue: document that zero is accepted as timeout value In-Reply-To: <1375883528.55.0.275850242187.issue18676@psf.upfronthosting.co.za> Message-ID: <1375926301.16.0.0875765880637.issue18676@psf.upfronthosting.co.za> Changes by Zhongyue Luo : Added file: http://bugs.python.org/file31188/queue_timeout_docstring.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 03:48:21 2013 From: report at bugs.python.org (Zhongyue Luo) Date: Thu, 08 Aug 2013 01:48:21 +0000 Subject: [issue18676] Queue: document that zero is accepted as timeout value In-Reply-To: <1375883528.55.0.275850242187.issue18676@psf.upfronthosting.co.za> Message-ID: <1375926501.16.0.776444156489.issue18676@psf.upfronthosting.co.za> Changes by Zhongyue Luo : Added file: http://bugs.python.org/file31189/queue_timeout_docstring.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 04:14:36 2013 From: report at bugs.python.org (Zachary Ware) Date: Thu, 08 Aug 2013 02:14:36 +0000 Subject: [issue18526] Add resource management/guarding to unittest In-Reply-To: <1374470490.47.0.980625465837.issue18526@psf.upfronthosting.co.za> Message-ID: <1375928076.45.0.919599109598.issue18526@psf.upfronthosting.co.za> Zachary Ware added the comment: (Apologies for the delay in replies, my available time evaporated without notice...) Antoine Pitrou wrote: > Does registerResource() mutate some kind of global per-process state? This > doesn't sound like a good idea. It's not the greatest of ideas, no; but I hadn't come up with a better one yet :). Robert's review has given me a couple ideas to try to avoid this, though. > (and even less so the "default resources", IMO: these are stdlib test > suite-specific) That is true, though I attempted to pick out some of the ones used by our test suite that are most likely to be applicable elsewhere. I had a couple misses, though, and I'm not against removing the defaults entirely. --- Michael Foord wrote: > My question is, is this generally useful enough for test suites beyond the > Python standard library. Essentially it provides a command line interface to > specialized test skipping. To be honest, I'm not sure. Theoretically, I can think of several situations where it would be useful, but I have no concrete examples aside from the Pytohn test suite. > I *still* feel that a generalized mechanism for adding command line options to > the standard test runner would allow for this and a myriad of other slightly > specialized use cases. It's hard to see how to do that cleanly without full > blown extension machinery (which I'm in favour of and have prototyped but it > is a *much* bigger change set) Is your prototype available anywhere for me to get a better idea what you mean? That could indeed be a much better approach if it is what I think it is. --- Robert Collins wrote: > I'll do a full review shortly, but at the conceptual level, I don't see any > benefit in making a new SkipTest base class, other than instantly breaking > other runners when an unknown exception is raised. SkipTest is part of the > API. Making a new exception part of the API requires a strong reason - not > just 'we want to show it differently' but 'we want the runner to behave > differently. Actually, the real reason I created the new _BaseSkip exception was to avoid an import loop between resources.py and case.py. I think I was trying to keep SkipTest defined in case.py, but in retrospect it is much saner to just move it to util.py and import from there in both other modules, and directly subclass SkipTest for the new Resource exceptions. I'll respond to your review on Rietveld and with a new patch, as time allows (hopefully before the next alpha). --- Thanks to all three of you for your comments :) ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 04:46:24 2013 From: report at bugs.python.org (Zachary Ware) Date: Thu, 08 Aug 2013 02:46:24 +0000 Subject: [issue16248] Security bug in tkinter allows for untrusted, arbitrary code execution. In-Reply-To: <1350401361.69.0.96754494265.issue16248@psf.upfronthosting.co.za> Message-ID: <1375929984.23.0.318212695424.issue16248@psf.upfronthosting.co.za> Zachary Ware added the comment: Antoine Pitrou wrote: > I've committed a fix to 2.7 (I hope it's really a fix, since I don't know how to test it). > I'll let Benjamin and Barry decide whether to backport to 2.6 and 3.2. > As for 3.1, it's pretty much dead. That fix does work, but it should probably get a NEWS entry since it fixes a regression from 2.7.3 to 2.7.5. Also, I think the same fix should be backported to all three of 2.6, 3.1, and 3.2. The same regression as in 2.7.5 exists in 3.2.5, and would be introduced by the next (last?) releases of 2.6 and 3.1. Sorry to have broken every possible version of Python :S ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 05:03:33 2013 From: report at bugs.python.org (Zachary Ware) Date: Thu, 08 Aug 2013 03:03:33 +0000 Subject: [issue18273] Simplify calling and discovery of json test package In-Reply-To: <1371760220.13.0.623339240586.issue18273@psf.upfronthosting.co.za> Message-ID: <1375931013.55.0.729393018561.issue18273@psf.upfronthosting.co.za> Zachary Ware added the comment: Here's a new patch; test_json.__main__ now uses an absolute import rather than trying to use a relative one. Also, Makefile.pre.in is fixed (thank you, Ned!). ---------- Added file: http://bugs.python.org/file31190/test_json_discovery.v2-3.3.diff _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 05:22:22 2013 From: report at bugs.python.org (Weizhao Li) Date: Thu, 08 Aug 2013 03:22:22 +0000 Subject: [issue18681] typo in imp.reload Message-ID: <1375932142.75.0.662721125733.issue18681@psf.upfronthosting.co.za> New submission from Weizhao Li: just a typo: 270c270 < raise ImportError(msg.format(parentname), name=parent_name) --- > raise ImportError(msg.format(parent_name), name=parent_name) ---------- components: Library (Lib) messages: 194641 nosy: felloak priority: normal severity: normal status: open title: typo in imp.reload type: behavior versions: Python 3.3 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 05:25:30 2013 From: report at bugs.python.org (Eric Snow) Date: Thu, 08 Aug 2013 03:25:30 +0000 Subject: [issue18677] Enhanced context managers with ContextManagerExit and None In-Reply-To: <1375885327.18.0.790620363467.issue18677@psf.upfronthosting.co.za> Message-ID: <1375932330.73.0.407804741125.issue18677@psf.upfronthosting.co.za> Eric Snow added the comment: Nick was probably talking about what is further elaborated in PEP 343. I'd recommend taking a particular look at the "Motivation and Summary" section regarding flow control macros. ---------- nosy: +eric.snow _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 05:29:39 2013 From: report at bugs.python.org (Zachary Ware) Date: Thu, 08 Aug 2013 03:29:39 +0000 Subject: [issue16968] Fix test discovery for test_concurrent_futures.py In-Reply-To: <1358201974.23.0.0352259739582.issue16968@psf.upfronthosting.co.za> Message-ID: <1375932578.99.0.990760989027.issue16968@psf.upfronthosting.co.za> Zachary Ware added the comment: That's a much better solution, thank you, Serhiy. Here's a new patch. test.support is no longer changed at all, but regrtest.py still is; the extra reference to the tests still causes issues, so it is removed. ---------- Added file: http://bugs.python.org/file31191/test_concurrent_futures_discovery.v5.diff _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 07:12:14 2013 From: report at bugs.python.org (Terry J. Reedy) Date: Thu, 08 Aug 2013 05:12:14 +0000 Subject: [issue18583] Idle: enhance FormatParagraph In-Reply-To: <1375065577.4.0.851490009653.issue18583@psf.upfronthosting.co.za> Message-ID: <1375938734.82.0.202718835846.issue18583@psf.upfronthosting.co.za> Changes by Terry J. Reedy : ---------- dependencies: +IDLE Unit test for FormatParagrah.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 07:18:35 2013 From: report at bugs.python.org (Terry J. Reedy) Date: Thu, 08 Aug 2013 05:18:35 +0000 Subject: [issue18226] IDLE Unit test for FormatParagrah.py In-Reply-To: <1371335636.99.0.534048602964.issue18226@psf.upfronthosting.co.za> Message-ID: <1375939115.66.0.886480425325.issue18226@psf.upfronthosting.co.za> Terry J. Reedy added the comment: Added tests to get 100% coverage (not counting in __name__ block). More test cleanups. Some of the extra newlines come from getting to 'end' instead of 'insert'. Others are avoided by adding newline to end of test strings, which is more realistic anyway. I commented out tests that I think test bad behavior that should be changed. ---------- Added file: http://bugs.python.org/file31192/18226FormatPara8.diff _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 08:44:55 2013 From: report at bugs.python.org (Larry Hastings) Date: Thu, 08 Aug 2013 06:44:55 +0000 Subject: [issue15301] os.chown: OverflowError: Python int too large to convert to C long In-Reply-To: <1341800139.98.0.546402243809.issue15301@psf.upfronthosting.co.za> Message-ID: <1375944295.35.0.514371908239.issue15301@psf.upfronthosting.co.za> Larry Hastings added the comment: Benjamin, do you want my elaborate fix in for 2.7? It means adding two new converters, one for pid and one for gid, and switching everything that takes pid/gid arguments to use those. ---------- nosy: +benjamin.peterson _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 09:23:02 2013 From: report at bugs.python.org (Roundup Robot) Date: Thu, 08 Aug 2013 07:23:02 +0000 Subject: [issue15301] os.chown: OverflowError: Python int too large to convert to C long In-Reply-To: <1341800139.98.0.546402243809.issue15301@psf.upfronthosting.co.za> Message-ID: <3c9gz96bMFz7M49@mail.python.org> Roundup Robot added the comment: New changeset f871f8662509 by Larry Hastings in branch 'default': Issue #15301: Parsing fd, uid, and gid parameters for builtins http://hg.python.org/cpython/rev/f871f8662509 ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 09:23:59 2013 From: report at bugs.python.org (Larry Hastings) Date: Thu, 08 Aug 2013 07:23:59 +0000 Subject: [issue15301] os.chown: OverflowError: Python int too large to convert to C long In-Reply-To: <1341800139.98.0.546402243809.issue15301@psf.upfronthosting.co.za> Message-ID: <1375946639.49.0.721500345543.issue15301@psf.upfronthosting.co.za> Larry Hastings added the comment: Now fixed in trunk. I am waiting to hear from Georg and the only-recently-pinged Benjamin to see if they want these fixes in 3.3 or 2.7. ---------- _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Aug 8 09:27:16 2013 From: report at bugs.python.org (Serhiy Storchaka) Date: Thu, 08 Aug 2013 07:27:16 +0000 Subject: [issue18290] json encoder does not support JSONP/JavaScript safe escaping In-Reply-To: <1372049179.79.0.237326954931.issue18290@psf.upfronthosting.co.za> Message-ID: <1375946836.55.0.638466333527.issue18290@psf.upfronthosting.co.za> Serhiy Storchaka added the comment: Embedding JSON inside