Skip to content

SDK drift: Python Exchange.escrow raises AttributeError for non-hosted-trading venues; TypeScript's escrow is always a safe undefined #1697

Description

@realfishsam

Drift

TypeScript declares escrow as a class field that is always present on every Exchange instance (as undefined until conditionally assigned), so reading exchange.escrow is always safe. Python only ever sets self.escrow inside the hosted-trading-allowlist conditional, with no default assigned anywhere else in __init__ — so for any Python exchange instance that isn't hosted-trading-allowlisted, exchange.escrow raises AttributeError.

TypeScript SDK

  • sdks/typescript/pmxt/client.ts:343public escrow?: Escrow; (always-declared field)
  • sdks/typescript/pmxt/client.ts:403-405 — conditionally assigned only for hosted-trading-allowlisted venues, but the declared field means exchange.escrow is always a safe read (undefined if unset).

Python SDK

sdks/python/pmxt/client.py:412-413:

if self.pmxt_api_key and self.exchange_name in HOSTED_TRADING_VENUES:
    self.escrow = Escrow(self)

No self.escrow = None default exists anywhere else in __init__ (verified via full-file grep).

Expected

Python's Exchange.__init__ should initialize self.escrow = None unconditionally before the conditional assignment, matching TypeScript's always-present-but-possibly-unset field semantics.

Impact

This is a real behavioral trap for anyone porting code like if exchange.escrow: ... from TypeScript docs/examples to Python — a plain local Polymarket() instance without pmxt_api_key, or any non-hosted-trading-allowlisted venue, will hard-crash with AttributeError: 'X' object has no attribute 'escrow' in Python instead of the TypeScript-equivalent safe undefined/falsy check.


Found by automated SDK cross-language drift audit

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions