[Python-Dev] shutil.copy() and hard links
Hello, here is another fun fact about links, this time hard links and the shutil.copy() function. The shutil.copy() functions behaves like the Unix cp(1) command. Both don't unlink the destination file if it already exists. As a consequence all hard links point to the updated file data. This behavior may surprise some users. Perhaps the docs should point out how shutil.copy() works when hard links join the party. It might be worth to add a function that works similar to install(1). The install(1) command unlinks the destination first and opens it with exclusive create flags. This compensates for possible symlink attacks, too. Christian Shell session example of cp and install === $ echo "test1" > test1 $ echo "test2" > test2 $ ln test1 test_hardlink now test_hardlink points to the same inodes as test1 $ cat test_hardlink test1 test_hardlink still points to the same inodes $ cp test2 test1 $ cat test_hardlink test2 reset $ echo "test1" > test1 $ cat test_hardlink test1 install unlinks the file first, test1 and test_hardlink point to different inodes $ install test2 test1 $ cat test_hardlink test1 strace of install test2 test1 = stat("test1", {st_mode=S_IFREG|0755, st_size=6, ...}) = 0 stat("test2", {st_mode=S_IFREG|0664, st_size=6, ...}) = 0 lstat("test1", {st_mode=S_IFREG|0755, st_size=6, ...}) = 0 unlink("test1") = 0 open("test2", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0664, st_size=6, ...}) = 0 open("test1", O_WRONLY|O_CREAT|O_EXCL, 0664) = 4 fstat(4, {st_mode=S_IFREG|0664, st_size=0, ...}) = 0 ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Python as a Metro-style App
Let me see if I can try this. Hopefully I still have my VM w/ this all setup and I can see if I can get it building this way. I can always ping some people on the C++ team and ask them for help if I run into issues. I'll give it a shot tomorrow and get back to you. Hi Dino, I reported that as a bug. If you need that for reference, see https://connect.microsoft.com/VisualStudio/feedback/details/717395/c1083-when-compiling-c-code-in-a-metro-app Regards, Martin ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Python C API: Problem sending tuple to a method of a python Class
On Wed, 11 Jan 2012 02:09:02 +0100 "Martin v. Löwis" wrote: > Am 10.01.2012 18:15, schrieb Matt Joiner: > > I suspect it actually would fix the confusion. "dev" usually means > > development, not "core implementation development". People float past > > looking for dev help... python-dev. Python-list is a bit generic. > > There is occasional confusion. More often, people think "there are the > folks who could actually answer my question, and nobody on python-list > answered, so I'll just ask there". We established to assume that they > are confused instead of deliberately breaking convention, which is a > polite way of pointing out that we really mean it. > > IOW, I think it is all fine the way it is. Typically, somebody answers > quickly. In this case, *two* people answered the same, which > a) really gets the message through, and > b) suggests that people are not too tired in actually typing in >this message every now and then. I suspect one of them doesn't actually *type* the message ;) Regards Antoine. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] os.walk() with followlinks=False
On Wed, 11 Jan 2012 12:25:46 +1000 Nick Coghlan wrote: > When discussing http://bugs.python.org/issue13734, Charles-François > noted that when os.walk() is called with "followlinks=False", symlinks > to directories are still included in the "subdirs" list rather than > the "files" list. > > This seems rather odd to me, so I'm asking here to see if there's a > specific rationale for it, or if it's just an artifact of the > implementation. > > If it's the latter... could we change it for 3.3, or is that too > significant a breach of backwards compatibility? I think we could change it. > Even if we can't change os.walk(), does os.walkfd() need to replicate > the annoying behaviour for consistency, or can it instead consider > such symlinks to be files rather than directories? IMO walkfd() should do the right thing. Regards Antoine. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Python C API: Problem sending tuple to a method of a python Class
On Wed, Jan 11, 2012 at 03:52:07PM +0100, Antoine Pitrou wrote: > On Wed, 11 Jan 2012 02:09:02 +0100 > "Martin v. L?wis" wrote: > > b) suggests that people are not too tired in actually typing in > >this message every now and then. > > I suspect one of them doesn't actually *type* the message ;) Certainly, no. :0r mail/misc/python-dev And even this command is in vim history, I don't type it, just press :0 ;-) Sometimes I add something useful to the OP but this time I didn't - I just haven't got any helpful information. Oleg. -- Oleg Broytmanhttp://phdru.name/p...@phdru.name Programmers don't die, they just GOSUB without RETURN. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Python as a Metro-style App
On Tue, Jan 10, 2012 at 4:20 PM, "Martin v. Löwis" wrote: >> Win 8 is practically a new OS target - the nt module may need to be >> replaced with a metro module to handle it well. > > No, it's not. Everything continues to work just fine on Windows 8, > as long as we keep developing desktop apps. > > Only if Metro Apps are the target things may need to be replaced (but > only very few changes are necessary to the nt module to make it compile). Yeah, that's what I meant. I should have said "WinRT is ..." instead of "Win 8 is ...". If nt can be made to work, than that's even better than I expected. - Jeff ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Proposed PEP on concurrent programming support
On Wed, 4 Jan 2012 00:07:27 -0500 PJ Eby wrote: > On Tue, Jan 3, 2012 at 7:40 PM, Mike Meyer wrote: > > A suite is marked > > as a `transaction`, and then when an unlocked object is modified, > > instead of indicating an error, a locked copy of it is created to be > > used through the rest of the transaction. If any of the originals > > are modified during the execution of the suite, the suite is rerun > > from the beginning. If it completes, the locked copies are copied > > back to the originals in an atomic manner. > I'm not sure if "locked" is really the right word here. A private > copy isn't "locked" because it's not shared. Do you have a suggestion for a better word? Maybe the "safe" state used elsewhere? > > For > > instance, combining STM with explicit locking would allow explicit > > locking when IO was required, > I don't think this idea makes any sense, since STM's don't really > "lock", and to control I/O in an STM system you just STM-ize the > queues. (Generally speaking.) I thought about that. I couldn't convince myself that STM by itself sufficient. If you need to make irreversible changes to the state of an object, you can't use STM, so what do you use? Can every such situation be handled by creating "safe" values then using an STM to update them? http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Python as a Metro-style App
Martin wrote: > See the start of the thread: I tried to create a "WinRT Component DLL", and > that failed, as VS would refuse to compile any C file in such a project. Not > sure whether this is triggered by defining WINAPI_FAMILY=2, or any other > compiler setting. > > I'd really love to use WINAPI_FAMILY=2, as compiler errors are much easier > to fix than verifier errors. I got the same errors as you - it seems like they're related to enabling the Immersive bit for the compile of the DLL. I'm not certain if that's necessary, when I did the run before to see if Python would pass the app store validation it didn't care that we didn't have the App Container bit set on the DLL (it did want NXCOMPAT and dynamic base set though). I was also able to just define WINAPI_FAMILY=2 in the .vcxproj file and I got the various expected errors when accessing banned APIs (it actually seems like a bunch were missing vs. what the validator reported, but maybe that's just an issue w/ the developer preview). Once I fixed those errors up I was able to get a DLL that successfully compiled. I'm going to ping some people on the windows team and see if the app container bit is or will be necessary for DLLs. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Proposed PEP on concurrent programming support
On Thu, Jan 12, 2012 at 11:01 AM, Mike Meyer wrote: > On Wed, 4 Jan 2012 00:07:27 -0500 > PJ Eby wrote: > >> On Tue, Jan 3, 2012 at 7:40 PM, Mike Meyer wrote: >> > A suite is marked >> > as a `transaction`, and then when an unlocked object is modified, >> > instead of indicating an error, a locked copy of it is created to be >> > used through the rest of the transaction. If any of the originals >> > are modified during the execution of the suite, the suite is rerun >> > from the beginning. If it completes, the locked copies are copied >> > back to the originals in an atomic manner. >> I'm not sure if "locked" is really the right word here. A private >> copy isn't "locked" because it's not shared. > > Do you have a suggestion for a better word? Maybe the "safe" state > used elsewhere? > >> > For >> > instance, combining STM with explicit locking would allow explicit >> > locking when IO was required, >> I don't think this idea makes any sense, since STM's don't really >> "lock", and to control I/O in an STM system you just STM-ize the >> queues. (Generally speaking.) > > I thought about that. I couldn't convince myself that STM by itself > sufficient. If you need to make irreversible changes to the state of > an object, you can't use STM, so what do you use? Can every such > situation be handled by creating "safe" values then using an STM to > update them? > > ___ > Python-Dev mailing list > Python-Dev@python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/anacrolix%40gmail.com IMHO STM by itself isn't sufficient. Either immutability, or careful use of references protected by STM amounting to the same are the only reasonable ways to do it. Both also perform much better than the alternatives. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com