|
bitprophet posted:So what, you say? Sure, that's no different at this level. But what if, instead of the file not existing, it does exist, but you don't have the right permissions? Does your file_exists() function test for that? Does it make sure the "file" isn't actually a directory? What about a broken symlink? A device file? Etc. Tell me, how does this distinguish file does not exist, file is a directory, file is not readable and (my personal favorite) EAGAIN. Python really struggles to carry some things to completion.
|
# ? Sep 8, 2010 10:51 |
|
|
# ? Apr 27, 2024 09:39 |
|
Zombywuf posted:Tell me, how does this distinguish file does not exist, file is a directory, file is not readable and (my personal favorite) EAGAIN. The point is, you don't really need to distinguish them. In most cases, your resolution will be "specify a valid file, dummy". The real problem is that you need to address all of them somewhere, so you can either explicitly check for them before opening the file (and then duplicate it in the exception logic in case it changes between the check and the actual access), or you can just try it and if it doesn't work, figure out how to deal with it then. Actually, the parenthetical statement is another important part. You have to write that exception logic anyway. Why not just skip the initial checks and deal with anything that goes wrong, when it actually goes wrong?
|
# ? Sep 8, 2010 11:34 |
|
Jabor posted:The point is, you don't really need to distinguish them. In most cases, your resolution will be "specify a valid file, dummy". Well, hopefully instead of laying out everything that can go wrong with a file you can use existing functionality and find a library function that does the work for you. Also, your exception advice is OK in Python but makes my Java eyes cringe.
|
# ? Sep 8, 2010 11:43 |
|
Jabor posted:The point is, you don't really need to distinguish them. In most cases, your resolution will be "specify a valid file, dummy". I'm going to take it from that that you don't know what EAGAIN means.
|
# ? Sep 8, 2010 13:08 |
|
Zombywuf posted:I'm going to take it from that that you don't know what EAGAIN means. I'm going to take it from that that you don't know what "most" means.
|
# ? Sep 8, 2010 13:33 |
|
I'm not a Pythonista by any account so don't take this as a defence of the language, but checking for EAGAIN can be rolled quite nicely into the IOError catch block, since errno is a field in the exception object you'll get passed. I think part of this argument stems from bitprophet being slightly off the mark when he had "print "No file :-("" in his catch block, since really all you know at that stage is that something went wrong, not that the file is missing (but, that's what e.errno is for!)
|
# ? Sep 8, 2010 14:36 |
|
JediGandalf posted:
You can check for those too but it's not just NullReferenceExceptions that are handled by that block.
|
# ? Sep 8, 2010 14:55 |
|
Jabor posted:I'm going to take it from that that you don't know what "most" means. I've seen more EAGAIN IOErrors in production than all other kinds of IOError combined.
|
# ? Sep 8, 2010 15:30 |
|
Zombywuf posted:I've seen more EAGAIN IOErrors in production than all other kinds of IOError combined. On what kind of application? I mostly see file missing, file already exists, and file permission. What kind of system are you on where EAGAIN is the most common IOError. Or are those others already handled, and you are talking about the remaining slice of errors?
|
# ? Sep 8, 2010 15:38 |
|
What is this ubiquitous EAGAIN error of which you all speak?
|
# ? Sep 8, 2010 16:39 |
|
It is when you do a syscall and the syscall is happily doing its thing and nothing is going wrong and then it suddenly returns -1 anyway because you received a signal or something dumb, and then you have to just do the same thing again and hope you do not get a syscall this time. Or a timeout, or whatever.
|
# ? Sep 8, 2010 16:48 |
|
litghost posted:On what kind of application? I mostly see file missing, file already exists, and file permission. What kind of system are you on where EAGAIN is the most common IOError. Or are those others already handled, and you are talking about the remaining slice of errors? Web, with many simultaneous processes.
|
# ? Sep 8, 2010 17:04 |
|
JediGandalf posted:What is this ubiquitous EAGAIN error of which you all speak? :manpage:
|
# ? Sep 8, 2010 18:55 |
|
Sometimes job candidates give weird answers, but why someone would do this escapes me. It's like he's trying to write himself a minivan:code:
|
# ? Sep 10, 2010 19:13 |
|
Paid by the SLOC?
|
# ? Sep 10, 2010 19:16 |
|
Just found out in one of our applications database credentials are being passed via a querystring through an iframe.
|
# ? Sep 10, 2010 20:12 |
|
I bet you just can't wait to see what happens on the backend!
|
# ? Sep 12, 2010 21:20 |
|
FinkieMcGee posted:Just found out in one of our applications database credentials are being passed via a querystring through an iframe. You mean the user enters credentials and they're submitted this way, or...?
|
# ? Sep 13, 2010 01:57 |
|
Okay, so our client uses a proprietary (ie: made up on the spot) internal xml format for exchanging data between its many many servers. This xml format contains a list, and each item in this list is a complex data type. You'd think at the very least the list items would look something like: code:
code:
That should have been enough of a red flag, but I hoped they would represent the contents of each item in a saner format. Instead we got: code:
After much begging, we finally got access to the code that builds these pipe-delimited strings. Apparently, these pipe-delimited strings are built by a stored proc in the database. The code retrieves this already pipe-delimited string from the db, PARSES OUT EACH ELEMENT, THEN RE-CONCATENATES THEM and returns the resulting string, which is of course exactly the same.
|
# ? Sep 13, 2010 07:19 |
|
Argue posted:That should have been enough of a red flag, but I hoped they would represent the contents of each item in a saner format. Instead we got: Are you working with airlines by any chance?
|
# ? Sep 13, 2010 13:19 |
|
Argue posted:After much begging, we finally got access to the code that builds these pipe-delimited strings. Apparently, these pipe-delimited strings are built by a stored proc in the database. The code retrieves this already pipe-delimited string from the db, PARSES OUT EACH ELEMENT, THEN RE-CONCATENATES THEM and returns the resulting string, which is of course exactly the same. If I were to build a factory where one of the assembly lines took objects apart and rebuilt them exactly the same, I'd probably be considered mad and sent to an asylum. Somehow the same does not apply to software engineering.
|
# ? Sep 13, 2010 16:48 |
|
Unless you tell your PHB that it's recycling and it saves money
|
# ? Sep 13, 2010 17:15 |
|
YeOldeButchere posted:If I were to build a factory where one of the assembly lines took objects apart and rebuilt them exactly the same, I'd probably be considered mad and sent to an asylum. Perhaps the intent was to validate the parts before rebuilding the string?
|
# ? Sep 13, 2010 18:59 |
|
Fly posted:Perhaps the intent was to validate the parts before rebuilding the string? But if you break a string apart and validate the pieces, why would you need to reassemble the string? You just friggin' had it!
|
# ? Sep 13, 2010 21:08 |
|
Maybe they were removing some invalid characters from one or more sections in the process? Ugh, I feel bad for trying to justify what is almost certainly a horrible, pointless trainwreck.
|
# ? Sep 13, 2010 22:31 |
|
The real horror is that you KNOW that at some point it has the information in discrete enough components to emit well-formed XML. In fact, it may have done that at one point in its lifetime.
|
# ? Sep 13, 2010 23:48 |
|
Vanadium posted:It is when you do a syscall and the syscall is happily doing its thing and nothing is going wrong and then it suddenly returns -1 anyway because you received a signal or something dumb, and then you have to just do the same thing again and hope you do not get a syscall this time. Or a timeout, or whatever. A little late, but. It's EINTR that's returned when a blocking syscall is interrupted by a signal. EAGAIN means a whole plethora of different things. Frequently it seems to overlap with EWOULDBLOCK. e: I would guess it stands for 'try again'. Habnabit fucked around with this message at 06:11 on Sep 16, 2010 |
# ? Sep 16, 2010 06:09 |
|
Hammerite posted:You mean the user enters credentials and they're submitted this way, or...? No like Database name (admittedly you need to be in the VPN to use this info), DB User, DB Password.
|
# ? Sep 18, 2010 01:21 |
|
Someone just committed code to the repository that errors at run time. They wanted some data that was stored in XML and instead of getting it from the location where it is already loaded into memory they wrote their own loading functions. Now this loader instead of using the application settings to get the path of the files has it hard coded. They needed data from two different types of XML. The first function is called ProcessXML, the second function is called ProceesXML. When I ask them if they knew they committed bad code. "oh someone must have changed it." Like hell, I see right there in the log you added your 500 lines where there was nothing and no one else has committed yet. When asked if they are going to fix it. "I don't know, it works for me." Edit: Best part, they are the lead on this project. Hibame fucked around with this message at 22:10 on Sep 19, 2010 |
# ? Sep 18, 2010 01:28 |
|
Hibame posted:When asked if they are going to fix it. Whenever we submit something that breaks on someone else's machine we always pull this out
|
# ? Sep 18, 2010 01:38 |
|
That is glorious.
|
# ? Sep 18, 2010 12:36 |
|
Ugg boots posted:Whenever we submit something that breaks on someone else's machine we always pull this out
|
# ? Sep 18, 2010 14:00 |
|
Ugg boots posted:
|
# ? Sep 18, 2010 14:10 |
|
code:
|
# ? Sep 19, 2010 05:28 |
|
It's amazing... not once does he actually use o[0].
|
# ? Sep 19, 2010 14:36 |
|
I've seen at least some terrible languages where 1 is the starting index of an array, not 0.
|
# ? Sep 19, 2010 16:48 |
|
Chairman Steve posted:I've seen at least some terrible languages where 1 is the starting index of an array, not 0. i think at one point the numerical recipes in c books had a thing where all the array indices went through some kind of macro or something that offset everything by one because the original code was all in fortran
|
# ? Sep 19, 2010 17:13 |
|
Chairman Steve posted:I've seen at least some terrible languages where 1 is the starting index of an array, not 0. I don't know how terrible they are, but this is the standard for a number of mathematical languages inlcuding Maple and Magma.
|
# ? Sep 19, 2010 17:25 |
|
Some languages like Pascal let you define start and end indices for arrays as whatever numbers you want.
|
# ? Sep 19, 2010 17:33 |
|
|
# ? Apr 27, 2024 09:39 |
|
Vaginal Engineer posted:I don't know how terrible they are, but this is the standard for a number of mathematical languages inlcuding Maple and Magma. lua's another one. http://userweb.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html
|
# ? Sep 19, 2010 17:45 |