Skip to content

Commit

Permalink
Made chr() noargs error vary between Python 3.4 and Python 3.5 style
Browse files Browse the repository at this point in the history
  • Loading branch information
kjcole committed May 24, 2017
1 parent 1429614 commit 3826963
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion batavia/builtins/chr.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var constants = require('../core').constants
var exceptions = require('../core').exceptions
var types = require('../types')

Expand All @@ -9,7 +10,18 @@ function chr(args, kwargs) {
throw new exceptions.TypeError.$pyclass('chr() takes no keyword arguments')
}
if (!args || args.length !== 1) {
throw new exceptions.TypeError.$pyclass('chr() takes exactly one argument (' + args.length + ' given)')
switch (constants.BATAVIA_MAGIC) {
case constants.BATAVIA_MAGIC_34:
throw new exceptions.TypeError.$pyclass('chr() takes exactly 1 argument (' + args.length + ' given)');

case constants.BATAVIA_MAGIC_35a0:
case constants.BATAVIA_MAGIC_35:
case constants.BATAVIA_MAGIC_353:
throw new exceptions.TypeError.$pyclass('chr() takes exactly one argument (' + args.length + ' given)');

default:
throw new builtins.BataviaError.$pyclass('Unsupported BATAVIA_MAGIC. Possibly using unsupported Python version (supported: 3.4, 3.5)');
}
}
return new types.Str(String.fromCharCode(args[0]))
// After tests pass, let's try saving one object creation
Expand Down

0 comments on commit 3826963

Please sign in to comment.