-3

I always heard that python was a language that was friendly to monkey patching... well now i need to monkey patch and know not what to do.

I specifically need to disable the 'raising' of a parsing exception to see if a iso parsing library behaves. It's not so simple, because i'm using libmirage (which is a cdemu a cd emulator underlying library, to treat the first track of any kind of mode2 form 1 or mixed like a iso so that the iso parser library pycdlib can read it.

This works almost perfectly except... some of the psx cds in the redump collection i'm testing this out raise a exception during the parsing in pycdlib because of various parsing errors:

PyCdlibInvalidISO: data in 3rd unused field not zero

\

ValueError: year is out of range

\

PyCdlibInvalidISO: File structure version expected to be 1

etc.

What i'm really looking for is to disable the raising of exceptions during parsing, since the information i'm looking for has nothing much to do with iso validation - basically the serial inside of a single txt file - and those isos are vetted by redump anyway.

Is there any way to do this without importing and editing the library myself?

i30817
  • 1,356
  • 2
  • 13
  • 26
  • 5
    You can't just catch the exceptions? – Carcigenicate Jan 05 '18 at 16:45
  • Catching them prevents the parsing from continuing in the pycdlib library code (it throws them out). I don't control the library, otherwise i'd already have hacked it. It was installed with pip from its github. Eventually i'd like to distribute the program or script to other people. – i30817 Jan 05 '18 at 18:44
  • You cannot suppress raise. You would need to pull the modules source and directly modify it, aka fork it. – alaricljs Jan 06 '18 at 01:17

1 Answers1

0

Well since there is no way to do this without forking i guess the best way is to either clone the repo with git and use pip -e ~/fork to install a modified version (or maybe just copy the repo to the local dir since it's pure python) or convince the upstream to be more permissive during parsing.

I did both.

i30817
  • 1,356
  • 2
  • 13
  • 26