Fedora ponders the Python 2 end game
Fedora ponders the Python 2 end game
Posted Aug 2, 2017 11:55 UTC (Wed) by Kamilion (guest, #42576)In reply to: Fedora ponders the Python 2 end game by niner
Parent article: Fedora ponders the Python 2 end game
*Holds up a copy of Perl 6 and Parrot Essentials (2003)*
*connects to VM*
~$ perl --version
This is perl 5, version 22, subversion 1 (v5.22.1) built for x86-linux-gnu-thread-multi (with 58 registered patches, see perl -V for more detail)
Copyright 1987-2015, Larry Wall
*scratches head*
Sooooooo, where's the perl6 I tried to learn 14 years ago, before resorting to learning python?
I mean, yeah, python3's taken a few years, but when you say you'd personally just use Perl, and after saying "Especially since they have not shown any sign of even acknowledging their mistake.", I find myself feeling somewhat amused and confused at the same time.
On the flip side, I try to take a lot of care that python code I touch runs in both 2.7 and 3.4+.
https://github.com/kamilion/customizer/commit/f0b5521ef30...
Fixing the compatibility issues between the versions using u'{}'.format(data) to ensure all data was unicode, even under python 2, wasn't really terribly difficult.
I've had more trouble trying to bring some old python 2.3 code back to life.
Posted Aug 2, 2017 12:05 UTC (Wed)
by lkundrak (subscriber, #43452)
[Link]
Posted Aug 2, 2017 12:08 UTC (Wed)
by niner (subscriber, #26151)
[Link] (15 responses)
And again in contrast to Python 2 -> 3, Perl 5 code can still be used via https://github.com/niner/Inline-Perl5/
Posted Aug 2, 2017 12:23 UTC (Wed)
by anselm (subscriber, #2796)
[Link] (14 responses)
So the Perl 6 developers did everything right except when they tried to figure out a name for their new language.
Frankly, I think that the issues with the Python-2-to-3 transition have been wildly overhyped. It is quite possible to write code that runs with both Python 2.7 and Python 3.x, and there are automated tools to help with that. The main mistake the Python developers made was to underestimate the time it would take to adapt various popular third-party libraries, but by now this is pretty much finished. I personally went over to Python-3-only for new code a while ago and haven't looked back.
Posted Aug 2, 2017 12:30 UTC (Wed)
by niner (subscriber, #26151)
[Link] (4 responses)
[1] http://docs.zope.org/zope2/zope2book/DTML.html#using-pyth...
Posted Aug 2, 2017 14:10 UTC (Wed)
by anselm (subscriber, #2796)
[Link] (1 responses)
Oh. DTML. That sucks. I feel your pain :^(
As far as I'm concerned, Zope did look like a good idea in the early 2000s or so but quickly became a liability. Fortunately I managed to move off it soon afterward. I'm using Django today, which by now works great with Python 3.
Incidentally, there seem to be enough people in situations similar to yours that Python 2.7 support might not go away completely in 2020. It's just that the head Python guys said it won't be them providing that support. In effect, starting today you people have more than two years to pool your money and get Python 2.7 LTS organised. It's not as if the code base required loads of TLC to keep running, so this may be cheaper in the end than moving millions of lines of code to something else.
Posted Aug 2, 2017 14:21 UTC (Wed)
by corbet (editor, #1)
[Link]
Posted Aug 2, 2017 16:35 UTC (Wed)
by smoogen (subscriber, #97)
[Link]
Posted Aug 2, 2017 18:54 UTC (Wed)
by Cyberax (✭ supporter ✭, #52523)
[Link]
Posted Aug 4, 2017 1:49 UTC (Fri)
by lsl (subscriber, #86508)
[Link] (8 responses)
I don't think so. I still see Python programs (allegedly supporting Python 3) heavily shitting themselves upon encountering data that cannot be decoded to Unicode. We're talking external data here, like stuff coming in over the network or user-created file names.
Posted Aug 4, 2017 4:23 UTC (Fri)
by smckay (guest, #103253)
[Link] (7 responses)
It does sound like the Unicode codecs have significant problems if exceptions are part of the default behavior. It's not like you can tell the socket/pipe/file to stop pulling your leg and cough up the <i>good</i> data. Rule #1 of text handling: do the best you can with what you're given and hope no one notices the ÃÆ.
Posted Aug 4, 2017 5:17 UTC (Fri)
by mbunkus (subscriber, #87248)
[Link] (2 responses)
It's really trivial to recreate. Take a non-ASCII file name on Windows, e.g. "möp.txt". Compress it into a ZIP, copy it to Linux and unzip it there. You'll end up with:
$ unzip the-zip.zip
The reason is simple: stupid file formats. There are no specs for file name encoding in ZIPs. There's no file name encoding indicator either. One could always use 7z, of course, where the specs state that file names be encoded in one of the Unicode encodings, but Windows doesn't come with support for 7z out of the box, but for ZIP. Aaaaand try getting people to use some new(ish) format and see how much success you have :(
Another thing that happens more often than I'd like is some mail program or other getting MIME wrong somehow so that an attachment containing non-ASCII characters in its file name being saved with the wrong encoding resulting in similar brokenness.
Posted Aug 7, 2017 20:15 UTC (Mon)
by cesarb (subscriber, #6266)
[Link] (1 responses)
Actually, there is. See appendix D of the ZIP spec at https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT which says:
- If bit 11 is set, the filename is in UTF-8
Posted Aug 8, 2017 2:40 UTC (Tue)
by smckay (guest, #103253)
[Link]
Posted Aug 4, 2017 8:36 UTC (Fri)
by Cyberax (✭ supporter ✭, #52523)
[Link]
For example, I have recently struggled with a Py3-based proxy server that failed with one broken client that sends non-ASCII header names.
Posted Aug 5, 2017 21:14 UTC (Sat)
by flussence (guest, #85566)
[Link] (2 responses)
The most programmer-abusive thing I've tried to use lately is actually perl6's binary types. There's no concept of endianness so the 16/32 bit wide variants are completely unusable for I/O… and they *only* work with I/O functions. You can't pack, unpack, recast to array or any other kind of high level operation on them. The rest of the language is (mostly) sane, but this forgotten corner has all the readability and portability of disassembled SIMD code with the performance of said asm being emulated in a high level language.
Posted Aug 7, 2017 11:12 UTC (Mon)
by niner (subscriber, #26151)
[Link] (1 responses)
That's not exactly true:
> perl6 -e '"Ödögödöckö".encode.List.say'
> perl6 -e 'use experimental :pack; pack("NNN", 1, 2, 3).say'
> perl6 -e 'use experimental :pack; pack("NNN", 1, 2, 3).unpack("NNN").say'
Posted Aug 9, 2017 20:58 UTC (Wed)
by flussence (guest, #85566)
[Link]
I'm talking about things like this:
Or, here's a basic “real world” example I just made up: Read two equal-size image files in farbfeld format, alpha composite them, and write out the result to a new file… what would idiomatic perl6 code for that look like? Probably shorter than this comment if these bits of the language worked, but they don't.
Sorry for what looks like nitpicking some obscure corner of the language, but I've seen a few too many people get burned out exploring these dark corners; they receive the silent treatment when they point out the language is getting in their way, and subsequently ragequit. There's a lot of this broken window syndrome outside of the cool-oneliner-demo APIs, and it's been like this since forever.
Fedora ponders the Python 2 end game
Fedora ponders the Python 2 end game
There's no need to port whole code bases to Perl 6. Perl 5 and Perl 6 code can live side by side in the same program, allowing for a piecemeal transition if so desired.
Fedora ponders the Python 2 end game
Fedora ponders the Python 2 end game
Fedora ponders the Python 2 end game
Way back around then, when I was working to replace the initial PHP-based LWN site, I did a prototype in Zope and DTML. Then I got distracted for a few months. When I came back to it I couldn't understand anything I'd done and had to start over from the beginning trying to figure out what all the weird wrapper layers did. I concluded that it would always be that way and started over with something else... I've never regretted that decision.
DTML
Fedora ponders the Python 2 end game
Fedora ponders the Python 2 end game
Fedora ponders the Python 2 end game
Fedora ponders the Python 2 end game
Wrong file name encoding made easy
Archive: the-zip.zip
inflating: mp.txt
$ ls -l
total 28
-rw-rw-r-- 1 mosu vj 18617 Aug 3 20:27 'm'$'\366''p.txt'
-rwxr--r-- 1 mosu vj 4272 Aug 4 07:07 the-zip.zip
$ rm m$'\366'p.txt
$ 7z x the-zip.zip
…snipped output…
$ ls -l
total 28
-rw-rw-r-- 1 mosu vj 18617 Aug 3 20:27 'm'$'\302\224''p.txt'
-rwxr--r-- 1 mosu vj 4272 Aug 4 07:07 the-zip.zip
Wrong file name encoding made easy
- If bit 11 is unset, the filename is in CP437
- The UTF-8 filename can also be in extra record 0x7075
Wrong file name encoding made easy
Fedora ponders the Python 2 end game
Fedora ponders the Python 2 end game
Fedora ponders the Python 2 end game
> perl6 -e '"Ödögödöckö".encode.say'
utf8:0x<c3 96 64 c3 b6 67 c3 b6 64 c3 b6 63 6b c3 b6>
(195 150 100 195 182 103 195 182 100 195 182 99 107 195 182)
Buf:0x<00 00 00 01 00 00 00 02 00 00 00 03>
(1 2 3)
Fedora ponders the Python 2 end game
> perl6 -e 'use experimental :pack; buf32.new(0x10203040, 1, 2, 3, 4).unpack("N").say'
4538991231697411
