SeattleTestbed / attic

ARCHIVAL: Full mirror of SeattleTestbed's SVN in early 2014. We use GitHub since!
MIT License
0 stars 1 forks source link

dylink legacy helper functions are unreliable #1367

Open choksi81 opened 10 years ago

choksi81 commented 10 years ago

dylink (see code, docs) includes functionality that should help to make "old" code dynamically linkable. This means code that uses the deprecated Repy preprocessor include syntax and/or print statements (which are disallowed in RepyV2 and must be supplanted by calls to log).

The helper functions, _replace_include and _replace_print aren't all that helpful however, and crash on a number of opportunities. Here are a few triggers I found:


Fail (include on first line of source file, not found by dylink's _replace_include and thus virtual_namespace trips with syntax violation):

include foo.repy

Workaround:

# Add a first line to the source file. Even "\n" only is fine.
include foo.repy

Fail (_replace_include treats whatever follows "include " as the filename, resulting in filenames with invalid characters here; variations with whitespace / comments after the filename crash too)


include        foo.repy

Fail (_replace_print detects "print >>" in comments and complains it can't turn redirected prints it into calls to log)

# print >>

Fail (_replace_print includes everything that follows "print " in log's arguments, including comments) --- ''was this meant in #1339?''

print "Hello world" # Comment of Death

The workarounds are pretty obvious (avoid the problematic idioms!). IMHO dylink need not try to fix code that's not valid RepyV2. include and print will raise errors during code safety checking, and the user should fix them correctly (rather than us fixing dylink to work in corner cases).

Also, we do not use the include syntax or print anymore. Let's get rid of the _replace_* functions, and make sure that our libraries don't rely on them.)