Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Re-raise the suppressed ValueError if calling 'typefunc()' without ar…

…guments failed in 'parse_inform_output'
  • Loading branch information...
commit d09152401a9e051b1ccd66e79d43ada12aebed4d 1 parent 79c347c
Jonas Haag authored

Showing 1 changed file with 11 additions and 2 deletions. Show diff stats Hide diff stats

  1. +11 2 lowlevel.py
13 lowlevel.py
... ... @@ -1,4 +1,5 @@
1 1 import os
  2 +import sys
2 3 from future_builtins import zip
3 4 from subprocess import Popen, PIPE
4 5 try:
@@ -15,6 +16,9 @@
15 16 class ExecutionError(Exception):
16 17 """ Raised if a MediaInfo command returns an exit code other than 0. """
17 18
  19 +def _raise(*exc_info):
  20 + raise exc_info[0], exc_info[1], exc_info[2]
  21 +
18 22 def format_inform(**inform):
19 23 sections = []
20 24 for section_name, params in inform.iteritems():
@@ -41,6 +45,7 @@ def parse_inform_output(output, inform):
41 45 values = params.split(PARAM_SEP)
42 46 sec = {}
43 47 for inform_param, value in zip(inform[section], values):
  48 + # TODO: put that typefunc stuff away
44 49 if isinstance(inform_param, basestring):
45 50 name, typefunc = inform_param, lambda x:x
46 51 else:
@@ -48,13 +53,17 @@ def parse_inform_output(output, inform):
48 53 try:
49 54 sec[name] = typefunc(value)
50 55 except ValueError:
  56 + value_error = sys.exc_info()
51 57 if value == '':
52 58 # if `value` is an empty string, try `typefunc` without
53 59 # arguments. useful e.g. for `typefunc` == `int`,
54 60 # which does not allow empty strings as argument.
55   - sec[name] = typefunc()
  61 + try:
  62 + sec[name] = typefunc()
  63 + except TypeError:
  64 + _raise(*value_error)
56 65 else:
57   - raise
  66 + _raise(*value_error)
58 67 sections[section] = sec
59 68 return sections
60 69

0 comments on commit d091524

Please sign in to comment.
Something went wrong with that request. Please try again.