Q: Why Python is bad for web from the point of URLs?
A: Because you need three modules to parse, edit and reassemble query string. urlparse, cgi and urllib -- http://mail.python.org/mailman/listinfo/python-list
Need a cross-platform way to execute binary
Hello, everyb. Does anybody know simple cross-platform method of probing if executable binary is available and launching it. Problem no.1: test if executable file is available I'll take windows platform as the most relevant in this case. os.access() doesn't handle env PATHEXT and can't detect if a given path would be executable or not. Here "executable" means file that could be be launched by system() (if there are any other ways - I'd be happy to know them) Suppose I have "ufo2exe" executable two directories up. >>> os.access("../../ufo2map.exe", os.X_OK) True However... >>> os.access("../../ufo2map", os.X_OK) False But... >>> os.system("..\..\ufo2map") ufo2map 1.0 0 Problem no.2: launch executable file The same windows platform again. All python commands are using forward slashes for paths, but system doesn't handle this situation (it could at least try to convert immediate forward slashes to backwards) os.access() thinks this file is executable, but os.system() fails ... >>> os.access("../../ufo2map.exe", os.X_OK) True >>> os.system("../../ufo2map.exe") '..' is not recognized as an internal or external command, operable program or batch file. 1 the contrary - access() fails to tell this path can be launched, but file Is executable, ... >>> os.access("..\..\ufo2map", os.X_OK) False >>> os.system("..\..\ufo2map") ufo2map 1.0 0 Is there any workaround in Python or I have to stick with platforms- specific quirks? I'm using Python 2.4.2 Thanks!. -- --t. -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a cross-platform way to execute binary
On Feb 10, 12:03 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > Does anybody know simple cross-platform method of probing if > > executable binary is available and launching it. > > > Problem no.1: test if executable file is available > > I'll take windows platform as the most relevant in this case. > > os.access() doesn't handle env PATHEXT and can't detect if a given > > path would be executable or not. Here "executable" means file that > > could be be launched by system() (if there are any other ways - I'd be > > happy to know them) > > > Suppose I have "ufo2exe" executable two directories up. > os.access("../../ufo2map.exe", os.X_OK) > > True > > > However... > os.access("../../ufo2map", os.X_OK) > > False > > That's right - such file does not exist. On Windows, in general, X_OK is > the same as F_OK: for any existing file, whatever name or extension, > returns True. Permissions are managed thru ACL and this simple function > does NOT consider them. It shouldn't matter if the file exists or not. Quoting http:// docs.python.org/lib/os-file-dir.html: " X_OK Value to include in the mode parameter of access() to determine if path can be executed. " See - there is no "file" notation as only "path" is tested and "path" is pretty executable. I think this should be clarified in os.access() documentation to make the whole business less confusing if not implemented in interpreter itself. After all the purpose of cross- platform language is to free developer from writing platform-specific code. > > > But... > os.system("..\..\ufo2map") > > ufo2map 1.0 > > 0 > > (Beware of single \ on normal strings!) > Use win32api.FindExecutable; should return the full path to ufo2map.exe. > "foo.txt" would return notepad.exe (or whatever you have associated to > text files). That is exactly what would be launched by os.system("foo.txt") Why isn't it possible to integrate the functionality in os.access() - IIUC Python interpreter still uses Windows API itself on this platform. > > Problem no.2: launch executable file > > The same windows platform again. All python commands are using forward > > slashes for paths, but system doesn't handle this situation (it could > > at least try to convert immediate forward slashes to backwards) > > Use os.path.normpath on the filename. (If you got it from FindExecutable > above, that would not be needed) > > > os.access() thinks this file is executable, but os.system() fails ... > os.access("../../ufo2map.exe", os.X_OK) > > True > os.system("../../ufo2map.exe") > > '..' is not recognized as an internal or external command, > > operable program or batch file. > > 1 > > > the contrary - access() fails to tell this path can be launched, but > > file Is executable, ... > os.access("..\..\ufo2map", os.X_OK) > > False > > Same as above - such file does not exist. Same as above - access() tests path, not file, so the argument is not valid. > os.system("..\..\ufo2map") > > ufo2map 1.0 > > 0 > > Is there any workaround in Python or I have to stick with platforms- > > specific quirks? > > I'm using Python 2.4.2 > > I think you will have to treat each platform differently. Just for > starting, the concept of "executable" is not the same across platforms. > But you could make some generic functions (with different implementations > on different platforms). I would prefer to know as little about underlying platforms as possible. It would only be a big plus for Python. -- --t. -- http://mail.python.org/mailman/listinfo/python-list
Determine minimum required version for a script
Can somebody remind how to check script compatibility with old Python versions? I can remember PHP_CompatInfo class for PHP that parses a script or directory to find out the minimum version and extensions required for them to run, and I wonder if there was anything like this for Python? -- --anatoly t. -- http://mail.python.org/mailman/listinfo/python-list
Re: [Twisted-Python] Announcing pyOpenSSL 0.12
Good news. It may worth to update http://wiki.python.org/moin/SSL with details. Right now it says that pyOpenSSL can not validate server identity. -- anatoly t. On Tue, Apr 12, 2011 at 3:19 AM, wrote: > Exciting news everyone, > > I have just released pyOpenSSL 0.12. pyOpenSSL provides Python bindings > to a number of OpenSSL APIs, including certificates, public and private > keys, and of course running TLS (SSL) over sockets or arbitrary in- > memory buffiers. > > This release fixes an incompatibility with Python 2.7 involving > memoryviews. It also exposes the "info callback" constants used to > report progress of the TLS handshake and later steps of SSL connections. > Perhaps most interestingly, it also adds support for inspecting > arbitrary X509 extensions. > > http://python.org/pypi/pyOpenSSL - check it out. > > Jean-Paul > > ___ > Twisted-Python mailing list > twisted-pyt...@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-Dev] [RELEASED] Python 3.2.1 rc 1
That's great, but where is the list if changes? -- anatoly t. On Tue, May 17, 2011 at 9:50 PM, Georg Brandl wrote: > On behalf of the Python development team, I am pleased to announce the > first release candidate of Python 3.2.1. > > Python 3.2.1 will the first bugfix release for Python 3.2, fixing over 120 > bugs and regressions in Python 3.2. > > For an extensive list of changes and features in the 3.2 line, see > > http://docs.python.org/3.2/whatsnew/3.2.html > > To download Python 3.2.1 visit: > > http://www.python.org/download/releases/3.2.1/ > > This is a testing release: Please consider trying Python 3.2.1 with your code > and reporting any bugs you may notice to: > > http://bugs.python.org/ > > > Enjoy! > > -- > Georg Brandl, Release Manager > georg at python.org > (on behalf of the entire python-dev team and 3.2's contributors) > ___ > Python-Dev mailing list > python-...@python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/techtonik%40gmail.com > -- http://mail.python.org/mailman/listinfo/python-list
Re: [Twisted-Python] Twisted 16.1 Release Announcement
Hi, Are there any plans to get back 32-bit wheels for Twisted? -- https://mail.python.org/mailman/listinfo/python-list
Re: [Twisted-Python] Twisted 15.4 was the last release to support Python 2.6; or: a HawkOwl Can't Words Situation
Is it possible to fix the documentation? https://twistedmatrix.com/trac/browser/tags/releases/twisted-15.5.0/NEWS?format=raw On Mon, Dec 7, 2015 at 4:06 PM, Amber "Hawkie" Brown wrote: > Hi everyone! > > It's been brought to my attention that I misworded something in the release > notes and it slipped through the cracks. In the NEWS I said: > >> This is the last Twisted release where Python 2.6 is supported, on any >> platform. > > However, I meant that this is the first Twisted release to drop 2.6 support > wholesale, preventing import on this platform. Twisted 15.4 will still > operate, so if you have Python 2.6 deployment requirements, bracket the > maximum to 15.4 on that platform by using an if statement in your setup.py, > and `Twisted >=*minreq*,<=15.4; python_version < '2.7'` under requires_dist > in your setup.cfg, where minreq is the minimum required Twisted. > > Sorry for the inconvenience! > > - Amber "HawkOwl" Brown > Twisted Release Manager > > ___ > Twisted-Python mailing list > twisted-pyt...@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > -- anatoly t. -- https://mail.python.org/mailman/listinfo/python-list
Re: [pydotorg-www] www.python.org - Backend is unhealthy
On Fri, May 8, 2015 at 11:32 AM, Noah Kantrowitz wrote: > > On May 8, 2015, at 10:28 AM, Chris Angelico wrote: > >> On Fri, May 8, 2015 at 6:17 PM, wrote: >>> I cannot access www.python.org. >>> I always get >>> >>> Error 503 Backend is unhealthy >>> >>> Backend is unhealthy >>> >>> Guru Mediation: >>> >>> Details: cache-ams4149-AMS 1431072956 2041303800 >>> >>> Varnish cache server >>> >>> >>> Is it only me? >>> >> >> No, it's not only you. I get the same but with different details: >> >> Details: cache-syd1627-SYD 1431073575 864283876 >> >> It looks to me as if my result is coming from a cache node in Sydney; >> yours is coming from some other cache node, so it's not just one node >> that's down. >> >> Cc'ing in the www list in case someone there knows, and I'll create a >> github issue to ping the people there. > > Should be recovering now. I see those once in a while. Not sure if it is only for PyPI, wiki or both. What is the reason? -- anatoly t. -- https://mail.python.org/mailman/listinfo/python-list
Fwd: Lossless bulletproof conversion to unicode (backslashing)
Hi. This was labelled offtopic in python-ideas, so I edited and forwarded it here. Please CC as I am not subscribed. In short. I need is a bulletproof way to convert from anything to unicode. This requires some kind of escaping to go forward and back. Some helper function like u2b() (unicode to binary) and b2u() (that also removes escaping). So far I can't find any code that does just that. Background story. I need to print SCons graph. SCons is a build tool, so it has a graph of nodes - what depends on what. I have no idea what a node object could be. I know only that it can have human readable representation. Sometimes node is a filename in some encoding that is not utf-8, and without knowing the encoding, converting it to unicode is not possible without loosing the information about that filename. So, here is what Python proposes: https://docs.python.org/2.7/library/functions.html?highlight=unicode#unicode unicode() type constructor that doesn't allow you to do conversion without losing the data. It offers only two basic strategies - crash or corrupt: 1. ignore - meaning skip and corrupt the data 2. replace - just corrupt the data 3. strict - just crash Python design leaves the decision how to implement safe interoperability to you, and that's basically the reason why Python 3 fails. Without a safe approach (get my binary data back frum that unicode) people just can't wrap their heads around that. Python design assumes that people know the encoding of data they are processing, but that's not true in many cases. The data may also be just broken or invalid. So, the real world coding assumptions are: 1. external data encoding is unknown or varies 2. external data has binary chunks that are invalid for conversion to unicode In real world UnicodeDecode crashes is not an option for deal with unknown or broken and invalid input (such as when I need to print human representation of Node to the screen). In many (most?) situations lossless garbage is more welcome than crash or dataloss and that should be a default behaviour. The solution is to have filter preprocess the binary string to escape all non-unicode symbols so that the following lossless transformation becomes possible: binary -> escaped utf-8 string -> unicode -> binary I want to know if that's real? I need to accomplish that with Python 2.x, but the use case is probably valid for Python 3 as well. This stuff is critical to port SCons to Python 3.x and I expect for other similar tools that have to deal with unknown ascii-binary strings too. -- anatoly t. -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: Lossless bulletproof conversion to unicode (backslashing)
On Wed, May 27, 2015 at 2:35 PM, Laura Creighton wrote: > I am missing something. Why do you need unicode at all? Why can you > not just keep your binary data as binary data? Good question. From the SCons code I see that we need unicode, because we switched to io.StringIO which is advertised as the future (and Python 3 way of doing things, because Python 3 doesn't have non-unicode StringIO). A really deep and exhaustive answer. advertisement (first link on StringIO vs io.StringIO): http://stackoverflow.com/questions/3410309/what-is-the-difference-between-stringio-and-io-stringio-in-python2-7 peaceful details https://bitbucket.org/scons/scons/commits/05d5af305a5d gory consequences https://bitbucket.org/scons/scons/pull-request/235/fix-tree-all-print-when-build-tree > I feel like I must be missing something obvious here ... Not that obvious as it appears. -- anatoly t. -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: Lossless bulletproof conversion to unicode (backslashing)
On Wed, May 27, 2015 at 2:47 PM, anatoly techtonik wrote: > On Wed, May 27, 2015 at 2:35 PM, Laura Creighton wrote: >> I am missing something. Why do you need unicode at all? Why can you >> not just keep your binary data as binary data? > > Good question. From the SCons code I see that we need unicode, because > we switched to io.StringIO which is advertised as the future (and Python 3 > way of doing things, because Python 3 doesn't have non-unicode StringIO). > > A really deep and exhaustive answer. > advertisement (first link on StringIO vs io.StringIO): > http://stackoverflow.com/questions/3410309/what-is-the-difference-between-stringio-and-io-stringio-in-python2-7 > peaceful details > https://bitbucket.org/scons/scons/commits/05d5af305a5d > gory consequences > https://bitbucket.org/scons/scons/pull-request/235/fix-tree-all-print-when-build-tree > >> I feel like I must be missing something obvious here ... > > Not that obvious as it appears. And the short answer is that we need unicode because we are printing this information to the stdout, and stdout is opened in text mode at least on Windows, and without explicit conversion, Python will try to decode stuff as being `ascii` and fail anyway. -- anatoly t. -- https://mail.python.org/mailman/listinfo/python-list
Subscribe to get an answer vs automatic CC Was: Fwd: Lossless bulletproof conversion to unicode (backslashing) (fwd)
On Wed, May 27, 2015 at 3:57 PM, Laura Creighton wrote: > Chris Angelico apparantly has a problem with cc'd people who aren't > on the list. I thought that CC in this case works automatically? If that's not the case, then I'll be annoyed by this too. So, thanks for CCing. =) Also, https://mail.python.org/mailman/listinfo/python-list - this page should probably mention that you need to subscribe to ask a question (people like me won't read it anyway, but it may help others). > python-list is very quiet these days, so if you > subscribe it won't be drinking from the firehose. 1688 / 29 = 58.206896551724135 msg/day don't look quiet, and I don't want to be distracted by interesting side threads, because I will accomplish nothing, get stressed, and things get worse at the end of the day. > And you can > always turn off delivery when you are done. Or you can just > go read the archives: > https://mail.python.org/pipermail/python-list/2015-May/thread.html I wish I could also commend from the web interface. I've heard Mailman 3.0 is stable, it will be interesting to see what is it capable of. -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: Lossless bulletproof conversion to unicode (backslashing) (fwd)
On Wed, May 27, 2015 at 3:57 PM, Laura Creighton wrote: > --- Forwarded Message > > Return-Path: > Received: from mail.python.org (mail.python.org [82.94.164.166]) > by theraft.openend.se (8.14.4/8.14.4/Debian-4) with ESMTP id > t4RC09ap02From: Chris Angelico > Cc: "python-list@python.org" > > > On Wed, May 27, 2015 at 9:52 PM, anatoly techtonik > wrote: >> And the short answer is that we need unicode because we are printing this >> information to the stdout, and stdout is opened in text mode at least on >> Windows, and without explicit conversion, Python will try to decode stuff >> as being `ascii` and fail anyway. > > So you're working with text. No. It is unknown. I am printing Nodes of SCons build graph and I don't know how Nodes are represented. In my case it appeared that Node contained Russian text, which led to crash of SCons. It could contain Russian text in cp1251 or in utf-8 or in KOI-8 and I can't do guessing of all possible encodings there. I just need to print that tree without crash or information loss. > That means you HAVE to decode it somehow; > you fundamentally cannot print bytes to the console. Lossless > concealment of arbitrary bytes won't help you. Won't help me with what? I am debugging build scripts to find out the *structure* of my dependencies and then all of the sudden Python crashes with UnicodeDecode error leaving me pronouncing bad Russian curses aloud. It is not even less forgiving than Java, but is also more treacherous, because of its run-time nature. It will surely help to preserve my zen if Python could just flow through the nodes of this graph. Garbage is okay - I can clean it up or remove if it stands in the way, just disrupt my flow or say me that now I want to deal with UnicodeDecode errors. Because I don't. > If you can't adequately > decode everything, either backslash-escape the rest, or use a > replacement character; you can't print out those bytes. Yes. How to backslash the rest in Python 2? In Python 3 there is some freaky "surrogateescape" error strategy, but what to do in Python 2? Replacement character is not a solution, because it is a data loss, and if I want to do post processing of graph log, I won't be able to recover the missing bits. > And no, I will not cc you. Subscribe to the list if you're going to > ask a question. Added Mailman to my suxx tracker: https://github.com/techtonik/suxx-tracker#mailman -- anatoly t. -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: Lossless bulletproof conversion to unicode (backslashing) (fwd)
On Fri, May 29, 2015 at 11:41 AM, Laura Creighton wrote: > In a message of Fri, 29 May 2015 11:05:07 +0300, anatoly techtonik writes: > >>Added Mailman to my suxx tracker: >>https://github.com/techtonik/suxx-tracker#mailman > > You are damning the wrong piece of software -- this is not a problem > with mailman; mailman doesn't care at all what software you use to > read mail and reply to it with. The problem is with the various > readers and repliers that people are using. In particular, people on > the other side of one the usenet -> python-list gateway may not be seeing > this as mail at all, or sending their replies as mail. Sounds legit. But middle ux in suxx stands for user experience, and Mailman still doesn't improve it. If Mailman could subscribe me automatically to the thread I am starting, that would resolve all the problems. > But back to your original problem. > > I still don't understand why you need to go from some lossless > representation of your filename, back to the original. It is just happened that the only way to get graph out of SCons is to print its tree representation. That worked fine until we switched to from StringIO to its io.StringIO unicode equivalent. Dumping binary stuff in text form is a very common and reliable way to backup and process data. Starting from SQL dumps to SVN dumps - all these formats are convenient to store, transmit and process. > You start > with the binary version of the filename -- a series of bytes which > turns out to be good Cyrillic text, but could be anything. Right, good Cyrillic text in utf-8, and Python 2.x uses 'ascii', so if Python 2.x used 'utf-8' as its default encoding, there won't be an issue. For now. But I realize that it is not enough, so I want 100% protection from unwanted crashes and data loss, so I want to backslash non-utf-8 bytes when converting the data to unicode. > You store > that as the first so many bytes of your file. If ever you need to have > the original representation of your filename, you already have it, > right there, by reading the first so many bytes of your file. Why > care about what the user sees as a filename? Not sure that I understand. I don't store anything in file. Build graph is a representation of filesystem structure with entries that may or may not exist. Node in build graph can also be a string that is never written to disk. When I dump graph, I have no idea how I will process it, but when I will need to identify some Node, grep it, find a reference to it, I want its representation (which may as well serve as ID) to be preserved to avoid conflicts and wrong interpretation due to data loss Hopefully now that my user story is clear, can you tell me how can I do this bulletproof unicode conversion in Python 2? =) -- anatoly t. -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: Lossless bulletproof conversion to unicode (backslashing) (fwd)
On Fri, May 29, 2015 at 2:39 PM, Laura Creighton wrote: > Do you know about the codecs module? > > reading http://pymotw.com/2/codecs/ may be useful if this is new to you. Does that work for Python 2 and Python 3? > Have you read https://www.python.org/dev/peps/pep-0293/ ? No. > Will backslashreplace do what you want? I don't know. I am sorry, but what is there the code that does this: binary -> escaped utf-8 string -> unicode -> binary I know about coding module, but I am not seeing a solution to crash-proof output from Python. Is inserting a custom codec class into every piece of code that I want to debug is the only solution? -- anatoly t. -- https://mail.python.org/mailman/listinfo/python-list
Encoding of Python 2 string literals
Hi, Is there a way to know encoding of string (bytes) literal defined in source file? For example, given that source: # -*- coding: utf-8 -*- from library import Entry Entry("текст") Is there any way for Entry() constructor to know that string "текст" passed into it is the utf-8 string? I need to better prepare SCons for Python 3 migration. Please, CC. -- anatoly t. -- https://mail.python.org/mailman/listinfo/python-list
About SCons Re: [Python-Dev] progress: compiling python2.5 under msys (specifically but not exclusively under wine) with msvcr80
On Thu, Jan 22, 2009 at 12:51 AM, Roumen Petrov wrote: >> >> Against 2.3, rejected due to dependence on SCons. >> Also appears to have been incomplete, needing more work. > > No it was complete but use SCons. Most of changes changes in code you will > see again in 3871. > I would better use SCons for both unix and windows builds. In case of windows for both compilers - mingw and microsoft ones. To port curses extension to windows I need to know what gcc options mean, what are the rules to write Makefiles and how to repeat these rules as well as find options in visual studio interface. Not mentioning various platform-specific defines and warning fixes. -- --anatoly t. -- http://mail.python.org/mailman/listinfo/python-list
Re: About SCons Re: progress: compiling python2.5 under msys (specifically but not exclusively under wine) with msvcr80
On Sat, Jan 24, 2009 at 12:28 AM, Roumen Petrov >> >> I would better use SCons for both unix and windows builds. In case of >> windows for both compilers - mingw and microsoft ones. To port curses >> extension to windows I need to know what gcc options mean, what are >> the rules to write Makefiles and how to repeat these rules as well as >> find options in visual studio interface. Not mentioning various >> platform-specific defines and warning fixes. > > Did you select one of existing curses library for windows ? I've selected PDCurses and successfully compiled the module and run demos manually - you may see the batch and the patch at http://bugs.python.org/issue2889 However, I was asked for VS2008 project file and this is where it all stopped for 8 months already. First I couldn't get the VS2008, then it refused to run on my W2K and now I can't get enough time to learn it (including that I have 50%/40% experience in PHP/Python and only 5%/5% C/Java). -- --anatoly t. -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-Dev] [RELEASED] 2.7 beta 1
On Sun, Apr 11, 2010 at 1:13 AM, average wrote: > > There are so many features taken from 3.0 that I fear that it will > postpone its adoption interminably (it is, in practice, treated as > "beta" software itself). By making it doctrine that it won't be > official until the next "major" Python release, it will encourage > those who are able, to just make the jump to 3.0, while those who > cannot will have the subtle pressure to make the shift, however > gradual. > Additionally, it will give the community further incentive > to make Python3 all that it was intended to be. Personally, the > timing of v3 prevented me from fully participating in that effort, > and, not ignoring the work of those who did contribute, I think many > of us feel that it has not reached its potential. The same problem. For me it was possible to participate in standard library development only after Python Alphas with Windows binaries were released. I could test both new features and old bugs. Having a requirement that every developer should be able to compile binaries has an adverse effect on the quality of standard library. The absence of public Roadmap also makes it hard to judge the aforementioned "desired potential". It could be possible to compile a public list like http://dungeonhack.sourceforge.net/Roadmap I am afraid of two things with forthcoming Python releases. 1. feature creeping 2. feature missing And an overview of Python development in the form of release timer and roadmap will remove the remnants of fear and uncertainty and surely attract new people for sprints. Regardless of said above it is great to feel the hard work behind the scenes that makes new releases popping up. Thanks. -- anatoly t. -- http://mail.python.org/mailman/listinfo/python-list