Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problmen with utf-8 #47

Closed
Tobychev opened this issue Mar 9, 2015 · 4 comments
Closed

Problmen with utf-8 #47

Tobychev opened this issue Mar 9, 2015 · 4 comments

Comments

@Tobychev
Copy link
Contributor

Tobychev commented Mar 9, 2015

Hello Stefano,
sometimes when I accidentally give a incorrect flag to the compiler, fobis will crash with a message ending like this:

File "FoBiS/src/main/python/fobis/Builder.py", line 457, in _compile
result = syswork(cmd)
File "FoBiS/src/main/python/fobis/utils.py", line 27, in syswork
return [error, str(output.decode("utf-8"))]
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in position 50: ordinal not in range(128)

Today I put a print statement in utils.syswork to see what the compiler was returning and saw:
gfortran: error: unrecognized command line option ‘-fdefault-integer-4’

So these ‘marks’ that gfortran sets around the offending flag crashes FoBiS and I never get to know what my error was :(

@szaghi
Copy link
Owner

szaghi commented Mar 9, 2015

Hi Thomas,

be careful, maybe you are not using the last version (the lines numbers seem to be different with the last version on github, that, in any case, is older than the one I am now working on... I hope to push the new version later today).

Anyhow, your issue is interesting because I have (erroneously) assumed to have already fixed... at least in my own version. The new syswork function I am using is

def syswork(cmd):
  """
  Function for executing system command 'cmd': for compiling and linking files.
  """
  error = 0
  try:
    output = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
  except subprocess.CalledProcessError as err:
    error = err.returncode
    output = err.output.encode("ascii", errors='ignore')
  return [error, output]

This should fix any ascii/unicod string issues...

For checking what goes wrong (a sort of debugging mode of FoBiS.py) you have the -verbose option that will have a very verbose ouput: it is available from version 1.5.2 https://github.com/szaghi/FoBiS/wiki/ChangeLog

Finally, be careful to pass quoted string as argument: argparse is bugged ... https://github.com/szaghi/FoBiS/wiki/Getting-Started#a-note-on-quoted-string-arguments

Later today I hope to give you a more precise response.

@Tobychev
Copy link
Contributor Author

Tobychev commented Mar 9, 2015

I last pulled on saturday, so I have what is on github right now; are the line numbers much different, or just off by one? As mentioned I put in a print statement by hand to see what the error text was before FoBiS died, so that's probably why its different.

I haven't put any options in quotation marks, I think they come from gfortran directly.

@szaghi
Copy link
Owner

szaghi commented Mar 9, 2015

Sure you are right,

Anyhow, my local version is now different from your, thus it is complicated for me to check this issue. I think if you substitute your syswork with the one I posted above and you use -verbose you should overcome this issue (until I push the new version later today) having the control on what is going wrong (i.e. see the gfortran error without the necessity to patch FoBiS...). The modification of syswork has been done just for this purpose: avoid FoBiS to exit with unclear message...

See you later.

@szaghi
Copy link
Owner

szaghi commented Mar 10, 2015

Hi Tomas, I have just pushed the new version (on both Github and PyPi). I close this Issue, but you reopen it if the issue persists.

See you soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants