The Toronto stock market turned slightly higher mid-morning Wednesday as traders hoped that Republicans and Democrats were set to announce a last-minute deal to avoid hitting the U.S. debt limit.The S&P/TSX composite index was up 16.08 points at 12,947.54, held back by weakness in the mining sectors.The Canadian dollar rose 0.17 of a cent to 96.51 cents US as the U.S. dollar weakened just hours before the debt limit is reached. At that point Washington will lose its ability to borrow and will be required to meet its obligations by relying on cash in hand and incoming tax receipts.U.S. indexes were sharply higher as traders also took in earnings from toymaker Mattel, Bank of America and PepsiCo that beat expectations.The Dow Jones industrials jumped 177.89 points to 15,345.9, the Nasdaq was ahead 40.62 points to 3,834.63 and the S&P 500 index was up 19.8 points to 1,717.86.Democrat Senate Majority Leader Harry Reid and Republican Minority Leader Mitch McConnell were hoping to come to an agreement later Wednesday to raise the debt ceiling and end a partial government shutdown and, if possible, hold votes later in the day.Negotiations between the two Senate leaders resumed after House of Representatives Speaker John Boehner tried to write legislation that would satisfy GOP lawmakers, especially conservatives. He crafted two versions of the bill, but neither made it to a House vote because both faced certain defeat.Boehner’s inability to produce a bill that would pass in his own chamber likely means he will have to let the House vote on a Senate compromise, even if that means it passes with strong Democratic and weak GOP support.Threats of a downgrade to U.S. debt also provided added incentive to get a deal done.Ratings agency Fitch warned after the close Tuesday that it was reviewing the government’s AAA credit rating for a possible downgrade, though no action was near. The firm, one of the three leading U.S. credit-ratings agencies, said that “the political brinkmanship and reduced financing flexibility could increase the risk of a U.S. default.”Commodities were generally off the worst lows of the session but the gold sector led decliners, down almost two per cent while December gold bullion in New York turned negative, losing $2.40 to US$1,270.80 an ounce. Goldcorp. (TSX:G) faded 53 cents to C$24.44.The base metals component eased almost one per cent as December copper on the Nymex dropped two cents to US$3.28 a pound. First Quantum Minerals (TSX:FM) gave back 32 cents to C$18.54.Ivanhoe Mines (TSX:IVN) jumped 11 cents or 5.16 per cent to $2.24 in the wake of reports of strong exploration results at a platinum mine project in South Africa.The industrials sector was down 0.2 per cent after SNC-Lavalin Inc. (TSX:SNC) said it now expects consolidated net income in fiscal 2013 to be in the range of $10 million to $50 million, sharply lower than earlier guidance in the range of $220 million to $235 million. Among other things, the engineering company blamed a number of money-losing legacy contracts and a $75-million charge related to a restructuring of its European operations. Its stock fell $2.31 , or 5.23 per cent, to $41.82.The energy sector was ahead 0.36 per cent and the November crude contract on the New York Mercantile Exchange erased early losses to trade up 52 cents at US$101.73 a barrel after closing Tuesday at its lowest level since early July. Niko Resources (TSX:NKO) climbed seven cents to C$3.30.It was a heavy earnings day in the U.S. PepsiCo posted earnings of US$1.91 billion, or $1.23 per share. That compared with $1.9 billion, or $1.21 per share, a year ago. Not including one-time items, the company said it earned $1.24 per share, seven cents better than analysts’ forecasts. Revenue rose two per cent to $16.91 billion, less than the $17.02 billion Wall Street expected. The company stood by its full-year earnings forecast and its shares gained $1.31 to US$81.91.Bank of America Corp. earned $2.5 billion, or 20 cents a share, in the July-September period, up from $340 million a year earlier and beating the 19 cents expected by financial analysts. Third-quarter revenue slipped to $22.2 billion from $22.5 billion, coming in close to the analysts’ forecast of $22 billion and its shares ticked up 22 cents to $14.46.Mattel’s third-quarter net income rose 16 per cent to $422.8 million, or $1.21 per share. That was up from $365.9 million, or $1.04 per share, in the prior-year period, buoyed by higher sales of American Girl and Monster High products and strength in all regions. Its performance beat Wall Street expectations and its shares ran ahead $1.61 to $43.16.European bourses were turned largely positive with London’s FTSE 100 index up 0.35 per cent while Frankfurt’s DAX was 0.55 per cent higher. The Paris CAC 40 was off 0.25 per cent.