Skip to content

Migrate codebase to Python 3#3

Open
asdf1011 wants to merge 1 commit into
masterfrom
dev_agent_python_3_migration
Open

Migrate codebase to Python 3#3
asdf1011 wants to merge 1 commit into
masterfrom
dev_agent_python_3_migration

Conversation

@asdf1011

Copy link
Copy Markdown
Owner

No description provided.

Comment thread bdec/encode/sequence.py
return constraint.limit.evaluate(context)
return value

def _sequence_int_value(self, value):

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary?

Comment thread bdec/inspect/param.py Outdated
from functools import cmp_to_key


def cmp(a, b):

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmd is a very general function; why do we need this?

Comment thread bdec/inspect/type.py

class ShouldEndType(IntegerType):
"""Parameter used to pass the 'should end' up to the parent."""
def __hash__(self):

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this to be hashable?

Comment thread bdec/output/instance.py
import bdec.output
import bdec.sequence as seq
import bdec.sequenceof as sof
from functools import reduce

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was reduce a built in, but no longer?

Comment thread bdec/output/xmlout.py
return False

def to_file(items, output, encoding="utf-8", verbose=False):
def to_open(items, output, encoding="utf-8", verbose=False):

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bad rename; keep it as to_file. Better perhaps would be write_to_file, but let's keep that change out for this change for now.

Comment thread bdec/test/decoders.py
# As gzip'ed files seek extremely poorly, we'll read the file completely into memory.
import gzip
datafile = StringIO.StringIO(gzip.GzipFile(data_filename, 'rb').read())
datafile = io.StringIO(gzip.GzipFile(data_filename, 'rb').read().decode('latin1'))

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should datafile be binary, not a string?

Comment thread bdec/test/testchoice.py
results.append((is_starting, entry))
except ConstraintError, ex:
pass
except ConstraintError as caught:

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use 'ex' here? Why use a temporary 'caught' which then gets renamed?

Comment thread bdec/data.py
def __init__(self, buffer):
assert isinstance(buffer, str), "Expected a string; got %s!" % repr(buffer)
buffer = _to_text_bytes(buffer)
assert isinstance(buffer, str), "Expected a string/bytes; got %s!" % repr(buffer)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should just expect bytes now...

Comment thread bdec/data.py
encoding -- The unicode encoding the data is in. """
try:
return unicode(self.bytes(), encoding)
return self.bytes().encode('latin1').decode(encoding)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for all locations like this where it uses latin1, it should be bytes

Comment thread bdec/expression.py
def __str__(self):
return "Missing context '%s' (have %s)" % (self.name,
', '.join("'%s'" % k for k in self.context.keys()))
', '.join("'%s'" % k for k in list(self.context.keys())))

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need a list here? We're just iterating over it?

Comment thread bdec/expression.py

def __div__(self, other):
return ArithmeticExpression(operator.div, self, other)
def __truediv__(self, other):

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remind me, what's the difference with truediv?

Comment thread regression/test.py
result = {}
regression_dir = os.path.dirname(__file__)
for name in os.listdir(regression_dir):
if name.startswith('__'):

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks magic... what's it here for?

@asdf1011 asdf1011 force-pushed the dev_agent_python_3_migration branch from cd67484 to 113ba0a Compare June 22, 2026 18:50
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

Successfully merging this pull request may close these issues.

1 participant